Copied to clipboard

Flag this post as spam?

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


  • Zakhar 171 posts 397 karma points
    Jan 04, 2013 @ 15:33
    Zakhar
    0

    How to get a list of nodes by document type from IEnumerable

    Hi guys,

    I need to get a list of nodes by type from a list which I get from Tags:

    @using umbraco.MacroEngines
    @using umbraco.cms.businesslogic.Tags

    var matchingNodes = Tag.GetNodesWithTags(searchFor).ToList();

    Tag.GetNodesWithTags() returns IEnumerable<CMSNode>

    I'm trying to do it something like this, but have no luck:

    var debates = matchingNodes.Where(t => t.NodeTypeAlias.Equals("Debate"));

    How can I do it? Thanks!

     

  • Edwin van Koppen 156 posts 270 karma points
    Jan 10, 2013 @ 10:07
    Edwin van Koppen
    0

    I'm doing it like this but i don't know if it's the right way?

    DynamicNode Root = new DynamicNode(-1);
    ViewBag.NewsItems = Root.Descendants("NewsDetail").Where(x => x.Visible).OrderByDescending(x => x.CreateDate).Take(3);

  • Zakhar 171 posts 397 karma points
    Jan 10, 2013 @ 10:44
    Zakhar
    0

    Thanks Edwin, I kow how to get descendants of a node, I need to get the list out of collection in this case. It's a matter of correct cast I guess, can't get it to work though.

  • Edwin van Koppen 156 posts 270 karma points
    Jan 10, 2013 @ 10:55
    Edwin van Koppen
    0

    It return IEnumerable<DynamicNode> so i don't understand what kind of list you want?

  • Zakhar 171 posts 397 karma points
    Jan 10, 2013 @ 11:58
    Zakhar
    0

    My question is not what type of list I want but how to get this list from a collection which I get from Tag.GetNodesWithTags() (I'm not using node.Descendants or node.Children here),

    Sorry if it's not clear, but my initial question explains it.

     

  • Edwin van Koppen 156 posts 270 karma points
    Jan 11, 2013 @ 15:07
    Edwin van Koppen
    0

    Sorry, same here. I'm just a beginner and never used tags.

Please Sign in or register to post replies

Write your reply to:

Draft