Could you please post a little more of your code (especially the first line) so we can work out what startNode is and what type of Razor you are using?
Ok, cool, so the main issue is that you are trying to do a lambda on a dynamic object, how about something like this (requires Umbraco v6.2+ or v7.1.2+)?
var excludesId = "1234,5678,2332";
var startNode = Umbraco.TypedContent(2323);
var childNodes = startNode.DescendantsOrSelf(4).Where(x => !x.Id.ToString().CsvContains(excludesId)).OrderBy("UpdateDate desc");
foreach (var page in childNodes.Take(1))
{
@page.Name
}
Exclude nodes by nodeid in foreach loop
I need to exclude a set of nodes by their id in a foreach loop...
I call my id's like this:
How Do I filter out the comma-separated list of nodeid's from childNodes...?
NOTE: Making an if-sentence inside the foreach-loop is not an option...!
Hi Robin,
Could you please post a little more of your code (especially the first line) so we can work out what startNode is and what type of Razor you are using?
Jeavon
Certainly :)
Ok, cool, so the main issue is that you are trying to do a lambda on a dynamic object, how about something like this (requires Umbraco v6.2+ or v7.1.2+)?
This is typical when I try to write Lambda:
:(
(I'm using Umbraco v. 7.1.4 by the way...)
Did you try the above snippet I posted?
Yes but I cannot use TypedContent:
I need to use :
How ever - the Lambda expression does not filter out any nodes as I whant to - I still se some certain nodes as should not be visible...
It will only sort on 1 (one) id - not a comma serpareted list of Ids
You need to use it otherwise you cannot use a lambda.
Like this:
I'll give it a try - about the sorting - it seems that it will only sort on 1 id - not a list of ids... :|
This one nailed it...: :)
is working on a reply...