Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 27, 2012 @ 13:11
    Fuji Kusaka
    0

    Hide "umbracoNaviHide = 1" page

    Hi,

    I have a site map where the i need to display all the pages and am actually using the ultimate structure.  Everything is working just fine until i notice that some of the pages that needs has a value set to true (umbracoNaviHide) are showing up.

    To be more precise this is how my structure looks like

    * content
    --www
    --- EN
    ---- Folder 1
    ----- Items (umbracoNaviHide set to true)
    ---- Folder 2
    ----- Items
    ----- Items (umbracoNaviHide set to true)
    ----- Items (umbracoNaviHide set to true)
    ---- Folder (NEWS umbracoNaviHide set to true but child nodes should be displayed) 
    ----- News Items
    ---- Folder (Media)
    ----- Media Items

    This is how my razor code

     

    @traverse(Model.NodeById(umbraco.library.GetDictionaryItem("sitePlan")))
    @helper traverse(dynamic node)    {    
        var values = new Dictionary<string, object>();   
    var maxLevel = 5;
        values.Add("maxLevel", maxLevel);
        var items = node.Children.Where("Level <= maxLevel", values);
        if (items.Count() > 0)    {
           <ul > 
            @foreach (var pages in items)        {
                if (pages.NodeTypeAlias == "section" || pages.NodeTypeAlias == "folder"){
                 <li>@pages.Name @traverse(pages)</li>  
                }
                     else{
                    <li><a href="@Library.If((pages.Children.Count() > 0 || pages.Where("jump")), pages.Children.First().Url, pages.Url)">@pages.Name</a> @traverse(pages)</li>
                }
            }
          </ul>  
        }
    }

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Sep 27, 2012 @ 19:58
    Jan Skovgaard
    0

    Hi Fuji

    I think you should be able to check on "Visible" somewhere i the code above.

    var items = node.Children.Where("Visible"); should do the trick - must admit that I'm not sure about how to write the syntax so you can check for both expressions. (Too much of a n00b at this still :D...Some would call me lazy).

    var items = node.Children.Where("Visible" && "Level <= maxLevel", values); perhaps?...

    Hope this helps.

    /Jan

  • Fuji Kusaka 2203 posts 4220 karma points
    Sep 28, 2012 @ 07:25
    Fuji Kusaka
    0

    Hi Jan,

    I did tried that as well but doing so will not display the Folders with umbracoNaviHide set to true. 

    var items = node.Children.Where(" Visible && Level <= maxLevel", values);
    Here instead i want to  display the folders and it sub pages according to the value set for "umbracoNaviHide".
    //fuji
Please Sign in or register to post replies

Write your reply to:

Draft