Copied to clipboard

Flag this post as spam?

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


  • Clair 36 posts 86 karma points
    May 24, 2011 @ 18:06
    Clair
    0

    Tree Navigation

    How would I be able to filter the decendants of a node, but have many types.

    var Decendants = Page.Descendants("nodeTypeAlias").Where("Visible")

    but what I need to do is something like...

    var Decendants = Page.Descendants("nodeTypeAlias1,nodeTypeAlias2,nodeTypeAlias3").Where("Visible")
  • Richard Boelen 61 posts 153 karma points
    May 28, 2011 @ 11:35
    Richard Boelen
    0

    you can check for nodetypes using:

     Model.Descendants().Where("NodeTypeAlias == \"nodeTypeAlias1\"");
    

    Checking multiple nodetypes doesn't seem to work, strange...I think it's a bug..

    Model.Descendants().Where("NodeTypeAlias == \"nodeTypeAlias1\" || NodeTypeAlias == \"nodeTypeAlias2\" ")
  • Richard Boelen 61 posts 153 karma points
    May 28, 2011 @ 14:33
    Richard Boelen
    0

    This seems to work:

    @{
      umbraco.MacroEngines.DynamicNodeList list = Model.Descendants();
      string[] nodeTypes = {"nodeTypeAlias1", "nodeTypeAlias2", "nodeTypeAlias3"};
      <ul>
      @foreach(dynamic item in list.Items.Where(x => x.Visible && nodeTypes.Contains(x.NodeTypeAlias))){
        <li>@item.Name</li>   
      }
      </ul>
    }

    Cheers, Richard

Please Sign in or register to post replies

Write your reply to:

Draft