I am using the below code on a Master Page to display a set of Navigational links that are controlled from the Homepage node, This works fine on the homepage but as soon as you navigate to a sub page the links disappear.
@{
if (CurrentPage.HasValue("relatedLinks") && CurrentPage.relatedLinks.ToString().Length > 2)
{
<ul>
@foreach (var item in CurrentPage.relatedLinks)
{
var linkUrl = (bool)item.isInternal ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.link;
var linkTarget = (bool)item.newWindow ? "_blank" : null;
<li><a href="@linkUrl" target="@linkTarget">@item.caption</a></li>
}
</ul>
}
}
Recursive Releated Links
Hi All
I am using the below code on a Master Page to display a set of Navigational links that are controlled from the Homepage node, This works fine on the homepage but as soon as you navigate to a sub page the links disappear.
The code above is from https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/related-links
How do I go about making this recursive so it can be seen on all pages? I am using Umbraco 7.5.3 and the code is in a Template not a partial view
Thanks
Ben
Hi Ben,
I have looked at your code, and what you need to do is go up to the root node and get the values from there.
You can do it with the code below.
Hope this helps,
/Dennis
Ahh, so simple but I couldn't work it out.
Thanks very much Dennis
is working on a reply...