Copied to clipboard

Flag this post as spam?

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


  • Martin 114 posts 313 karma points
    Oct 28, 2014 @ 14:08
    Martin
    0

    umbracoNaviHide and "NotVisible"

    How do you write to get all pages where umbracoNaviHide is set to true (checked), i.e. what is the opposite to CurrentPage.Children.Where("Visible") ?   I tried "NotVisible" but it didn't work.

    Or does anybody know if it possible to set a default value to umbracoNaviHide?

    What I want to optain is basically "umbracoNaviShow" instead, meaning that I want to actively choose if the page should be in the navigation instead of actively choose if it shound not.

    Thanks for any suggestions,

    Martin

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 29, 2014 @ 19:04
    Dennis Aaen
    0

    Hi Martin.

    The way that you can do this is by add a property to your document type of the type true false, give it a name, and a alias. As you said you could give it a name e.g Show in navigation and a alias of umbracoNaviShow.

    Then you should be able to do this in your razor code, with this it only shows pages in the navigation that have the show in navigation option checked.

    @{
        @* Get the root of the website *@
        var root = CurrentPage.AncestorOrSelf(1);
    }

    <ul>
        @foreach (var page in root.Children.Where("umbracoNaviShow"))
        {
            <li class="@(page.IsAncestorOrSelf(CurrentPage) ? "current" : null)">
                <a href="@page.Url">@page.Name</a>
            </li>
        }
    </ul>

    Hope this helps,

    /Dennis

  • Martin 114 posts 313 karma points
    Oct 31, 2014 @ 10:32
    Martin
    0

    Thanks for the example Dennis.

    While trying to find an alternative by myself I found that using .Where("Visible == False") instead of .Where("Visible == True") or .Where("Visible"), would also work if one what to keep "umbracoNaviHide" as is.

    //

    Martin


Please Sign in or register to post replies

Write your reply to:

Draft