- content -homepage - who we are - the history - out ethos - your visit - getting around - things to do
-contact us
I want to get everything under the homepage (which I could hardcode as it will never change. the structure is suckerfish so it is a 'top' nav for the top list and nested ul's for the subnav. And finally I need to determine the current page so I can add a class="current page" to it, I have setup an umbracoNaviHide on the document types so anything I do not want can be excluded from the Nav
navigation with Razor
Hi,
my structure is like this
- content
-homepage
- who we are
- the history
- out ethos
- your visit
- getting around
- things to do
-contact us
I want to get everything under the homepage (which I could hardcode as it will never change.
the structure is suckerfish so it is a 'top' nav for the top list and nested ul's for the subnav. And finally I need to determine the current page so I can add a class="current page" to it, I have setup an umbracoNaviHide on the document types so anything I do not want can be excluded from the Nav
Many thanks
Hi Rocoeh,
You can get your razor navi to work this way
//fuji
Thanks this is close, modified your text a bit because I did not need the home link as my logo is the page home link. I am not getting the sub menu
the html should be something like this
<u id="main-nav">
<li class="level1"><a href="">item1</a>
<ul class="subnav">
<li><a href="">sub nav item1</a></li>
<li><a href="">sub nav item2</a></li>
<li><a href="">sub nav item3</a></li>
</ul>
</li>
<li class="level2"><a href="">item1</a>
<ul class="subnav">
<li><a href="">sub nav item1</a></li>
<li><a href="">sub nav item2</a></li>
<li><a href="">sub nav item3</a></li>
</ul>
</li>
</ul>
<ul id="main-nav">
@{
var terraNode = Model.AncestorOrSelf(1);
@terraNode;
const string selectedClass = " class=\"current page\"";
foreach(var page in terraNode.Children.Where("Visible")) {
<[email protected](page.IsAncestorOrSelf(Model), selectedClass)>
<a class="level1" href="@page.Url" title="@page.Name">@page.Name</a>
</li>
}
}
</ul>
Hi Rocoeh,
Did you get it working ?
//fuji
Hi Fuji,
No I get no 2nd level should there be an embeded if statement?
Ho Rocoeh,
Yes you have to include and if statement in your loop to check for any child nodes.
This should get your navigation drop down working
//fuji
is working on a reply...