Copied to clipboard

Flag this post as spam?

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


  • Dmitriy 168 posts 588 karma points
    Nov 16, 2017 @ 11:19
    Dmitriy
    0

    How to filter pages where children in listview?

    Hello. I render navigation recursivly and collided with a problem: I don't want to render items that is a list of items like blog.

    What I want:

    // Navigation
    Page 1 (has children)
    -- sub-page 1
    -- sub-page 2
    Page 2 (no children)
    Blog (has a lot of children)
    

    So, I would create a property in blog like "isListView" to filter by it, but may be exists a builtin property to do the same?

  • Michaël Vanbrabandt 863 posts 3343 karma points c-trib
    Nov 16, 2017 @ 11:23
    Michaël Vanbrabandt
    1

    Hi Dimitry,

    yes you are correct, Umbraco has a builtin property called umbracoNaviHide.

    To use this, you need to add a new property of type true/false where you change the alias of the property to: umbracoNaviHide.

    Then you can filter your list by using .Where("Visible") and then you will only get the items where this property is set to false.

    Hope this helps.

    /Michaël

  • Dmitriy 168 posts 588 karma points
    Nov 16, 2017 @ 12:12
    Dmitriy
    0

    Hi, Michaël

    To use this, you need to add a new property of type true/false where you change the alias of the property to: umbracoNaviHide.

    I know about this property, but I don't want to hide parant to list page from navigation, I only want to hide all of children and dont force users to check umbracoNaviHide

    Like:

    Blog (not hidden) 
    -- blog-post-1 (hidden)
    -- blog-post-2 (hidden)
    
  • Matt Darby 28 posts 389 karma points c-trib
    Nov 16, 2017 @ 12:17
    Matt Darby
    100

    Depending on how you have coded your nav, you could for example exclude the blog posts by their document type alias:

    .Where(x => x.DocumentTypeAlias != "blogPost")
    
  • Dmitriy 168 posts 588 karma points
    Nov 16, 2017 @ 12:29
    Dmitriy
    0

    Hi, Matt

    I thought about that and I don't like that way, because it is not universal. What if sitetree will be axtended another listview that is not blogpost?

    Now I thinking about trying to add a composition document type with one property like "isList" and add it type to every ListView document type

  • 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