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
I am trying to create a simple navigation but seem to be struggling... This is not working when I thought it should? Any tips appreciated.
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); var bCategories = @Model.AncestorOrSelf(level); if (bCategories != null) { <ul id="mainnavigation"> @foreach (var cat in bCategories.Children("nodeTypeAlias == \"BusinessCategory\"").Where("Visible").OrderBy("SortOrder")) { <li><a href="@cat.Url">@cat.Name</a></li> } </ul> } }
I keep getting the error
Cannot invoke a non-delegate type
Seems its where I call the DocType that is causing an issue, if I remove
("nodeTypeAlias == \"BusinessCategory\"")
It works, but defeats te object as I need to filter by both level AND DcoType
Got it working in the end
@inherits umbraco.MacroEngines.DynamicNodeContext @{ var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); var bCategories = @Model.AncestorOrSelf(level); if (bCategories != null) { <ul id="mainnavigation"> @foreach (var cat in bCategories.Children.Where("nodeTypeAlias == \"BusinessCategory\"").Where("Visible").OrderBy("SortOrder")) { <li><a href="@cat.Url">@cat.Name</a></li> } </ul> } }
It's populating dynamicnodelists on nodetypealias - so this should actually also work (and I think orderby should be the default sort order, ?):
@foreach (var cat in bCategories.BusinessCategory.Where("Visible"))
What if there are multiple nodeTypeAliases to check for? Would Lee's solution be the correct way to do it then?
Thanks,
Jason
Lee
You just saved my ass with:
Where("nodeTypeAlias == \"BusinessCategory\"")
I really needed to find a way in razor to stop all my DateFolders showing in nagivation.
Thanks
Paul
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Getting Nodes By Level & DocType
I am trying to create a simple navigation but seem to be struggling... This is not working when I thought it should? Any tips appreciated.
I keep getting the error
Cannot invoke a non-delegate type
Seems its where I call the DocType that is causing an issue, if I remove
It works, but defeats te object as I need to filter by both level AND DcoType
Got it working in the end
It's populating dynamicnodelists on nodetypealias - so this should actually also work (and I think orderby should be the default sort order, ?):
What if there are multiple nodeTypeAliases to check for? Would Lee's solution be the correct way to do it then?
Thanks,
Jason
Lee
You just saved my ass with:
I really needed to find a way in razor to stop all my DateFolders showing in nagivation.
Thanks
Paul
is working on a reply...