For making a sub navigation like this you could use the pre-code snippet called List Subpages From CurrentPage, and then you will need to make some changes to get exactly what you have pictured.
I have make a piece of code that should do it for you, or at least a good starting point.
The code Dennis has supplied will do that for direct children of the currentpage - this is the same code that will output the children depending on what page you're on.
See the selection line (line 1)
@{ var selection = CurrentPage.Children.Where("Visible"); }
If you mean you want it to list all children regardless of level below, i.e. all Descendants, not just those directly below then it's easy to change that line to:
@{ var selection = CurrentPage.Descendants().Where("Visible"); }
I really think you need to take some time out trying to make this site and follow some of the tutorials and learn Razor and the basics of looping through Umbraco content.
Johan,
Have you checked out NavIt MVC? It's an easy to customize MVC Partial View which might do what you're looking for. We've used it with very good results. https://our.umbraco.org/projects/starter-kits/navit-mvc/ Cheers Steve
Making a side navigation
I would like a side navigation that lists the submenus of a menu (just like a dropdown navigation would)
Here is an example:
How would the partial macro look like?
Hi Johan,
For making a sub navigation like this you could use the pre-code snippet called List Subpages From CurrentPage, and then you will need to make some changes to get exactly what you have pictured.
I have make a piece of code that should do it for you, or at least a good starting point.
Hope this helps,
/Dennis
Hi Dan, Thank you. However, I want to make that sub navigation act as siblings. How can I achieve that?
The code Dennis has supplied will do that for direct children of the currentpage - this is the same code that will output the children depending on what page you're on.
See the selection line (line 1)
If you mean you want it to list all children regardless of level below, i.e. all Descendants, not just those directly below then it's easy to change that line to:
However this will list them all at the same level. I've even given you this hint in your main nav question. https://our.umbraco.org/forum/developers/razor/73017-sub-menu-drop-down-under-entire-menu#comment-234638
I really think you need to take some time out trying to make this site and follow some of the tutorials and learn Razor and the basics of looping through Umbraco content.
Follow this tutorial and the videos here in a separate project and you should find everything else much easier in the future: https://our.umbraco.org/documentation/tutorials/creating-basic-site/
http://umbraco.tv/videos/implementor/working-with-umbraco-data/razor-syntax/introduction-to-razor/
Johan,
Have you checked out NavIt MVC? It's an easy to customize MVC Partial View which might do what you're looking for. We've used it with very good results.
https://our.umbraco.org/projects/starter-kits/navit-mvc/
Cheers
Steve
is working on a reply...