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
Hi guys!
I want to have my home node dynamically in my navigation menu - but have do I achieve that?
This is my code:
@{ var selection = CurrentPage.Site().Children.Where("Visible"); } <ul class="nav navbar-nav"> @*<li><a class="page-scroll" href="/forside/">forside</a></li>*@ @foreach (var item in selection) { <li class="@(item.IsAncestorsOrSelf(CurrentPage) ? "active" : null)"> <a href="@item.Url">@item.Name</a> </li> } <li><a class="page-scroll" href="#kontakt">Kontakt os</a></li>
I could just hardcode my home node, but then, I can't use my the umbracoNaviHide function.
So can anyone please help with this?
Thanks in advance,
//Sharmarke
I have not tested it but it should work.
@{ var RootNode = CurrentPage.AncestorsOrSelf().Last(); }
Hi Aristotelis,
I've tried your solution:
@{ //var selection = CurrentPage.Site().Children.Where("Visible"); var RootNode = CurrentPage.AncestorsOrself.First().Where("Visible"); } <ul class="nav navbar-nav"> @*<li><a class="page-scroll" href="/forside/">forside</a></li>*@ @foreach (var item in RootNode) { <li class="@(item.IsAncestorsOrSelf(CurrentPage) ? "active" : null)"> <a href="@item.Url">@item.Name</a> </li> } <li><a class="page-scroll" href="#kontakt">Kontakt os</a></li>
But all of my menu items disappeared in my navigation - did I do something wrong?
Hi Sharmarke!!
Try this:
@{ var home = CurrentPage.Site(); var children = home.Children.Where("Visible"); } <ul class="nav navbar-nav"> <li><a class="page-scroll" href="@home.Url">@home.Name</a></li> @foreach (var item in children) { <li class="@(item.Id == CurrentPage.Id ? "active" : "")"> <a href="@item.Url">@item.Name</a> </li> } <li><a class="page-scroll" href="#kontakt">Kontakt os</a></li></ul>
Hi Dennis!!
Thank you very much for your help and time - your solution worked very well for me - I appreciate it!
Awsome Sharmarke, great to hear that it worked out for you and glad i could help. Good luck with the rest of you site and have a great day!!
Thanks - and you too!
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
Getting the "Home" node in dynamically in the navigation menu
Hi guys!
I want to have my home node dynamically in my navigation menu - but have do I achieve that?
This is my code:
I could just hardcode my home node, but then, I can't use my the umbracoNaviHide function.
So can anyone please help with this?
Thanks in advance,
//Sharmarke
I have not tested it but it should work.
Hi Aristotelis,
I've tried your solution:
But all of my menu items disappeared in my navigation - did I do something wrong?
//Sharmarke
Hi Sharmarke!!
Try this:
Hi Dennis!!
Thank you very much for your help and time - your solution worked very well for me - I appreciate it!
//Sharmarke
Awsome Sharmarke, great to hear that it worked out for you and glad i could help. Good luck with the rest of you site and have a great day!!
Thanks - and you too!
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.