foreach(var site in siteMap.Children.Where("Visible"))
{
var excludesId = "1174,1175,1176,1178,1180,1181,1182,1183,1184,1185,1186,1187".Split(',');
<a href="@site.Url">@site.Name</a>
<br>
foreach(var child in site.Descendants().Where(x=> !x.GetPropertyValue<bool>("excludeFromSiteMap")))
{
<a href="@child.Url">@child.Name</a><br>
}
}
Throws the same error ("Cannot use a lambda expression as an argument to a dynamically dispatched operation"). I have made a checkbox on the ID's I want excluded, checked those that I want excluded, but still gives me this error.
Exclude content ID from siteMap
Hello.
I'm trying to make a siteMap, sort of in my own way. I know there are other ways to do this, but I'd like to try this way.
My site is as follows
I would like to exclude Name 1 and 2.
I have the ID's of the Contents that I want excluded, but I can't loop through them. I've tried this:
But it spews an error because of the lambda expression.
Any suggestions?
Hi Pedman,
There are a few options available to you.
1) Instead of having excludesId as a string you could try having it as an array/list.
Then you could do:
2) Alternatively, you could add a checkbox property to your documents and call it "exclude from sitemap"
Then you don't have to have a hard coded list, instead you could do:
The latter would be a much more flexible approach :-)
Nik
var siteMap = Umbraco.Content(1064);
Throws the same error ("Cannot use a lambda expression as an argument to a dynamically dispatched operation"). I have made a checkbox on the ID's I want excluded, checked those that I want excluded, but still gives me this error.
Thanks a ton for helping me
Ahh, okay.
So, personally I am not a fan of dynamic content. If I can I try and use typed content as I prefer it.
I would change the line where you are getting your siteMap to this:
This might resolve the issue relating to dynamics.
Nik
That worked.
Thank you very much for the fast replies and the precise help :)
Have a good day :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.