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
Is there any way to check whether a node is a descendants of a certain node?
I'd like to check with this code. But it doesnt work
@if(CurrentPage.IsAncestorsOrSelf(1122)) { Html.RenderPartial("Submenu/About"); }
Is there any other way to do this? Thanks!
Hi rendervouz.
You are very close, try this example:
@if (Umbraco.Content(1122).IsAncestorOrSelf(CurrentPage)) { @Html.RenderPartial("Submenu/About") }
Or, you can reverse the logic, by doing:
@if (CurrentPage.IsDescendantOrSelf(Umbraco.Content(1122))) { @Html.RenderPartial("Submenu/About") }
Best of luck to you! Take care!
Hi Rendervouz.
I think they reason why is not working for is because it should be:
@if(CurrentPage.IsAncestorOrSelf(1122)) { Html.RenderPartial("Submenu/About"); }
So the different here is IsAncestorOrSelf and not IsAncestorsOrSelf You have these options
.IsAncestor(DynamicPublishedContent,valueIfTrue[,valueIfFalse]) .IsAncestorOrSelf(DynamicPublishedContent,valueIfTrue[,valueIfFalse]) .IsDescendant(DynamicPublishedContent,valueIfTrue[,valueIfFalse]) .IsDescendantOrSelf(DynamicPublishedContent,valueIfTrue[,valueIfFalse]
Hope this helps,
/Dennis
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Check if a certain node is the descendants of a node
Is there any way to check whether a node is a descendants of a certain node?
I'd like to check with this code. But it doesnt work
Is there any other way to do this? Thanks!
Hi rendervouz.
You are very close, try this example:
Or, you can reverse the logic, by doing:
Best of luck to you! Take care!
Hi Rendervouz.
I think they reason why is not working for is because it should be:
So the different here is IsAncestorOrSelf and not IsAncestorsOrSelf You have these options
Hope this helps,
/Dennis
is working on a reply...