Copied to clipboard

Flag this post as spam?

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


  • Jacob Bach Pedersen 19 posts 73 karma points
    Oct 01, 2014 @ 15:29
    Jacob Bach Pedersen
    0

    umbracoNaviHide does not work

    Hey

    I just tryed to get umbracoNaviHide to work. Added a True/false datatype to my Page documenttype, named umbracoNaviHide.

    I reader my menu like this:

    @foreach(page in Umbraco.ContentAtRoot().DescendantsOrSelf("Frontpage").First().Children.Where("Visible"))

    but it stills renders the hidden pages. Can anybody tell me why?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 01, 2014 @ 21:17
    Dennis Aaen
    0

    Hi Jacob,

    I have just tried your code, against the starter kit, Umbraco 7.1.6, the only thing I can see that is missing in your code is the var in the front of the page.

    @foreach(var page in Umbraco.ContentAtRoot().DescendantsOrSelf("Frontpage").First().Children.Where("Visible")){ 

    }

    If I then try to hide a page by set tick in the umbracoNaviHide, then the page is hidden from the navigation. To make it clear it´s the propertyAlias that should have the value of umbracoNaviHide

    So the only thing I can see that is missing is the var before the page in the forech-loop. If it doesn't work, then maybe you could try to describe your content structure, maybe there can be something there.

    Hope this helps,

    /Dennis

  • Jacob Bach Pedersen 19 posts 73 karma points
    Oct 02, 2014 @ 08:50
    Jacob Bach Pedersen
    0

    Hej

    My code is:

    @helper RenderMenu(IEnumerable<IPublishedContent> nodes)
    {
        foreach (var node in nodes)
        {                               
            <li>
                <a href="@node.Url" title="@node.Name">@node.Name</a>
                @if (node.Children.Any())
                {
                    <ul class="menu-item-sub">
                        @RenderMenu(node.Children)
                    </ul>
                }
            </li>
        }
    }
    
    @RenderMenu(Umbraco.ContentAtRoot().DescendantsOrSelf("Frontpage").First().Children.Where("Visible"))
    

    And the field on my page document type:

    Umbraco setup

    Im also running 7.1.6. Thats strange, i think i need to debug this.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 02, 2014 @ 09:12
    Dave Woestenborghs
    0

    The problem is that when you call render menu again to render submenu's you don't have the where clause to only show visible items

     

    Dave

  • Jacob Bach Pedersen 19 posts 73 karma points
    Oct 02, 2014 @ 09:40
    Jacob Bach Pedersen
    0

    Yes. Thats right. Thanks.

  • 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.

Please Sign in or register to post replies