Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I have a related content partial view that gets similar animal pages to the one the user has selected:
@foreach (var page in Umbraco.Content("1061").DescendantsOrSelf("Animal"))
{}
Is there any way to tell it "Where ID is not = to current page ID?" i dont want to see the current page in the related section choices.
Thanks guys,
J
P.S. I am using Umbraco.Content(1061) sot hat i can stick the partial view anywhere on my site.
TY
Hi James,
I think that you could do something like this
@{ var currentPageId = CurrentPage.Id; foreach (var page in Umbraco.Content("1061").DescendantsOrSelf("Animal").Where("Visible && Id != @0",currentPageId)){ // Do something } }
And here you can find the documentation https://our.umbraco.org/Documentation/Reference/Mvc/querying#Complexquerying%28Where%29
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Id of current page
Hello,
I have a related content partial view that gets similar animal pages to the one the user has selected:
@foreach (var page in Umbraco.Content("1061").DescendantsOrSelf("Animal"))
{}
Is there any way to tell it "Where ID is not = to current page ID?" i dont want to see the current page in the related section choices.
Thanks guys,
J
P.S. I am using Umbraco.Content(1061) sot hat i can stick the partial view anywhere on my site.
TY
Hi James,
I think that you could do something like this
And here you can find the documentation https://our.umbraco.org/Documentation/Reference/Mvc/querying#Complexquerying%28Where%29
Hope this helps,
/Dennis
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.