Copied to clipboard

Flag this post as spam?

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


  • Johan 95 posts 264 karma points
    Nov 23, 2015 @ 13:51
    Johan
    0

    How to make Main Navigation not originate from Home

    I'm trying to make my Navigation not to originate from Home. The reason is because I have three top links and I want each Top links to have its own navigation.

    So what I want to do is to somehow originate from the top links I have enter image description here

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Nov 23, 2015 @ 15:10
    Alex Skrypnyk
    0

    Hi Johan,

    Can you show your code of navigation?

  • Johan 95 posts 264 karma points
    Nov 23, 2015 @ 15:17
    Johan
    0

    Here is the code of my MainNavigation:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{ var home = CurrentPage.Site(); }
    
    @if (home.Children.Any())
    {
    
    
    
        @* Get the first page in the children *@
        var naviLevel = home.Children.First().Level;
        @* Add in level for a CSS hook *@
        <div class="linje"></div>
        <ul class="meny level-@naviLevel">
            @* For each child page under the home node *@
            @foreach (var childPage in home.Children)
    {
    
        if (childPage.Children.Any())
        {
    
            <li class="dropdown has-child @(childPage.IsAncestorOrSelf(CurrentPage) ? "selected" : null)">
                @if (childPage.DocumentTypeAlias == "Huvudmeny")
                {
                    <span>@childPage.Name</span>
                    @childPages(childPage.Children)
                }
                else
                {
                    <a href="@childPage.Url" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">@childPage.Name</a>
                }
    
                @helper childPages(dynamic pages)
    {
                @* Ensure that we have a collection of pages *@
    
        if (pages.Any())
        {
            @* Get the first page in pages and get the level *@
            var naviLevel = pages.First().Level;
    
            @* Add in level for a CSS hook *@
    
        <ul class="meny dropdown-menu sublevel level-@(naviLevel)">
            @foreach (var page in pages)
            {
                <li>
                    <a href="@page.Url">@page.Name</a>
    
                    @* if the current page has any children *@
                    @if (page.Children.Any())
                    {
                        @* Call our helper to display the children *@
                        @childPages(page.Children)
                    }
                </li>
            }
        </ul>
        }   
    }
            </li>            
        }
    
        else
        {
                  <li class="@(childPage.IsAncestorOrSelf(CurrentPage) ? "selected" : null)">
                      <a href="@childPage.Url">@childPage.Name</a>
                 </li>
                }   
            }
        </ul>
           <div class="linje col-md-12" ></div>
    }
    
  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Nov 23, 2015 @ 16:57
    Alex Skrypnyk
    0

    Johan,

    As I understand Home page is on the same level as another pages, so you can remove it from menu if you restrict it by index or doctype.

  • Johan 95 posts 264 karma points
    Nov 24, 2015 @ 07:49
    Johan
    0

    How can I restrict it by doctype?

Please Sign in or register to post replies

Write your reply to:

Draft