I'm pretty new to this so apologies if this is a stupid question.
I'm trying to show a link to whatever node is an ancestor of the current page immediately below the root. This could be the current page if it is immediately below the root.
I think what you are looking for is the AncestorOrSelf(int: maxLevel) method. The int parameter specifies what level ancestor of the current node you want, where 1 is the root node.
In your case, you´d want to specify 2 since you dont want the root node, but instead the 2 level node ancestor from the current node.
Strong type example:
@Model.Content.AncestorOrSelf(2)
Dynamic example:
@CurrentPage.AncestorOrSelf(2)
Or:
If I have misunderstood you , and you mean that you ALWAYS want to show the first child of the root node ("Section 1"), no matter where you are on the website, then this is what you want.
Show node 1 below root in ancestors
Hi,
I'm pretty new to this so apologies if this is a stupid question.
I'm trying to show a link to whatever node is an ancestor of the current page immediately below the root. This could be the current page if it is immediately below the root.
E.g.
Home - Section 1 - Page 1 - Page 2 - Subpage 99 - Section 2 - Page 3 - Page 4
If I'm on either "Section 1", "Page 1", "Subpage 99" or "Page 2" the link would show 'Section 1".
I've read many forum posts and am tearing my hair out. I don't understand why I can't find the answer!
Any help gratefully received.
Thank you
Hi Alex.
I think what you are looking for is the AncestorOrSelf(int: maxLevel) method. The int parameter specifies what level ancestor of the current node you want, where 1 is the root node. In your case, you´d want to specify 2 since you dont want the root node, but instead the 2 level node ancestor from the current node.
Strong type example:
Dynamic example:
Or:
If I have misunderstood you , and you mean that you ALWAYS want to show the first child of the root node ("Section 1"), no matter where you are on the website, then this is what you want.
Strong type example:
Dynamic example:
Hope this was helpful!
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.