I want to find a collection of content nodes that have certain conditions, one of them being a check to see if the page is protected. Ideally that would be possible inside a .Where() but at least in 4.7RC it isn't. You can vote for this feature at http://umbraco.codeplex.com/workitem/30096
Until then, I will need to create my own DynamicNodeList with a 'for' loop, checking each item for various conditions. I've tried the following but they don't work.
// get starting list of potential nodes to search
DynamicNodeList nodesToSearch = @Model.DescendantsOrSelf().Where("umbracoNaviHide != true");
// remove nodes that are protected ((this code does NOT work))
DynamicNodeList possibleNodes = new DynamicNodeList();
foreach (DynamicNode node in nodesToSearch) {
if (!node.IsProtected()) {
possibleNodes.Add(node);
}
}
// remove nodes that are protected ((this code does NOT work))
List<DynamicNode> possibleNodes = new List<DynamicNode>();
foreach (DynamicNode node in nodesToSearch) {
if (!node.IsProtected()) {
possibleNodes.Add(node);
}
}
How can I create my own variable that contains the nodes I want for later use?
Creating a DynamicNodeList with a 'for' loop
Using Umbraco 4.7RC
I want to find a collection of content nodes that have certain conditions, one of them being a check to see if the page is protected. Ideally that would be possible inside a .Where() but at least in 4.7RC it isn't. You can vote for this feature at http://umbraco.codeplex.com/workitem/30096
Until then, I will need to create my own DynamicNodeList with a 'for' loop, checking each item for various conditions. I've tried the following but they don't work.
How can I create my own variable that contains the nodes I want for later use?
cheers,
doug.
Wait a minute... on of those DOES work! The solution is:
Sorry for the confusion.
cheers,
doug.
How does the second one not work? It works fine for me, any errors?
Haha, too late with my reply, as usual =)
For future reference, had to include a using statement:
is working on a reply...