Copied to clipboard

Flag this post as spam?

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


  • Greg Lee 5 posts 25 karma points
    Aug 12, 2010 @ 23:30
    Greg Lee
    0

    How do I get all nodes based on a Property Value

    Greetings all!

    We're trying to find an efficent way to get all of the nodes (children) of a node that have a specific property we have created and designated in its template.  Essentially, we have a "true/false" property that users can check/uncheck, and we want to gather all nodes that have that value checked.

    Any simple with (with or without Linq) to do this?  We're currently attempting to this in .net... but we're open to suggestions.

     

    This is what I got so far... but there has to be a more effecient way to do this... without the recursive for loop...

     private void GetChildrenOfNodeWithCalendarEnable(Node node, string propertyName, bool propertyValue)
            {
                foreach (Node child in node.Children)
                {
                    if (Convert.ToBoolean(child.GetProperty(propertyName).Value) == propertyValue)
                    {
                        this.allNodes.Add(child);
                    }

                    if (child.Children.Count > 1)
                    {
                        this.GetChildrenOfNodeWithCalendarEnable(child, propertyName, propertyValue);
                    }
                }
            }

     

    Let me know?  Best wishes, and thanks in advance!!!


    Greg

  • Sascha Wolter 615 posts 1101 karma points
    Aug 13, 2010 @ 00:42
    Sascha Wolter
    0

    Hi Greg,

    Here is an alternative way: http://our.umbraco.org/forum/developers/xslt/11304-NodeFactory.

    Cheers,
    Sascha

     

Please Sign in or register to post replies

Write your reply to:

Draft