Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi
I've got a problem with the where method on the Ancestors collection.
I've got a look that just loops all parent items which works.
@foreach (var parent in @Model.Ancestors().Where("umbracoNaviHide != true")){ <li><a href="@parent.Url">@parent.Name</a></li>}
I've now modified the code to get only Ancestors where Level > 2
@foreach (var parent in @Model.Ancestors().Where("Level > 2 && umbracoNaviHide != true")){ <li><a href="@parent.Url">@parent.Name</a></li>}
According to the post Razor features walkthough 4 you can do multiple commands in a where by adding || (or) or && (and)
I'm totally lost on this one any help would be great.
Cheers
Jon
May help if you know what error I receive!
Error loading Razor Script NavigationLeft.cshtml
Incorrect number of parameters supplied for lambda declaration
I got round multiple wheres by doing multiple wheres
i.e .where("Level > 2").where("Visible")
Actually I did it the other way round in my code .Where("Visible").Where("Level > 2") but don't know if that will make a difference
nice idea Lee, reads better as well..
(May have a slight performance hit but I don't know enough about the internals)
I also found I had to do it this way in 4.7.0 with the multiple Where's
There's a problem with the code in 4.7 that breaks Where() and OrderBy() - it's a known issue and apparently will be fixed... see http://our.umbraco.org/forum/developers/razor/18373-DynamicNodeListWhere-marked-as-private-in-47final?p=1
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
@Model.Ancestors().Where() problem
Hi
I've got a problem with the where method on the Ancestors collection.
I've got a look that just loops all parent items which works.
I've now modified the code to get only Ancestors where Level > 2
According to the post Razor features walkthough 4 you can do multiple commands in a where by adding || (or) or && (and)
I'm totally lost on this one any help would be great.
Cheers
Jon
May help if you know what error I receive!
Error loading Razor Script NavigationLeft.cshtml
Incorrect number of parameters supplied for lambda declaration
I got round multiple wheres by doing multiple wheres
i.e .where("Level > 2").where("Visible")
Actually I did it the other way round in my code .Where("Visible").Where("Level > 2") but don't know if that will make a difference
nice idea Lee, reads better as well..
(May have a slight performance hit but I don't know enough about the internals)
I also found I had to do it this way in 4.7.0 with the multiple Where's
There's a problem with the code in 4.7 that breaks Where() and OrderBy() - it's a known issue and apparently will be fixed... see http://our.umbraco.org/forum/developers/razor/18373-DynamicNodeListWhere-marked-as-private-in-47final?p=1
is working on a reply...