Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dot Test 3 posts 83 karma points
    Dec 11, 2015 @ 12:20
    Dot Test
    0

    HederMenu

    Hello, I want to create a dynamic header menu and i am using umbraco 7 macros(partial view).Please suggest me to creating dynamic menu or there is any other way to create?

  • TheOriginal 22 posts 122 karma points
    Dec 11, 2015 @ 13:11
    TheOriginal
    100

    If you go into partial views, then right click and to create one, in the drop down menu there will be various options, select navigation and this would provide something like this:

    @{ var selection = CurrentPage.Site().Children.Where("Visible"); }
    
    <ul class="menuClass">
        @foreach(var item in selection)
        {
              <li class="@(item.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
                  <a href="@item.Url">@item.Name</a>
              </li>
         }
     </ul>
    

    This is the default code that will provide a dynamic navigation menu, when ever your create a new page in the content section the navigation will update it's self. To use this in your code you simply write:

    @Html.Partial("PartialName")
    

    That will render the partial make sure to saround in any parent elements.

  • Dot Test 3 posts 83 karma points
    Dec 14, 2015 @ 05:14
    Dot Test
    0

    Thank you your suggestion applied it successfully. But if i have to create a dynamic menu then i am getting some confusion..... My scenario- I created a master template @template and create a document type home and my all pages are home document type which is using a master layout. when i create a navigation. its giving me first page dropdown(pages) and not showing main pages

Please Sign in or register to post replies

Write your reply to:

Draft