Get Children of Specific NodeTypeAlias or DocumentTypeAlias V6
I am trying to list the children page links of a DocumentType GeneralInformaion. The children are just Textpages. I Have tried numerous things with this Partial View and had no luck. This was easy when we had Razor macro engines because I could use NodeByID() not so easy with V6. The General Information is using umbracoNavihide not to be listed in the Nav.
I have tried
@foreach (var page in Model.Content.Children.Where("NodeTypeAlias == \"GeneralInformation\"").First.Children)
{
Parser Error Message: Expected a "{" but found a "var". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
Compiler Error Message: CS0119: 'Umbraco.Web.PublishedContentExtensions.Children(Umbraco.Core.Models.IPublishedContent)' is a 'method', which is not valid in the given context
Source Error:
Line 8:
Line 9:
Line 10: @foreach (var page in Model.Children.Where("NodeTypeAlias == \"GeneralInformation\"").Where("Visible"))
Line 11: {
Line 12:
If i read u headline and question correct u jumped on the mvc train and what to know how to filter children based on document type. if so then all u need to do is send regular linq to u where statement instead of the "amputated" string version like so
That works! Thank you!!! At least on my home page. All other templates it comes up blank. I guess it cannot find the route? do you have any suggestions?
Get Children of Specific NodeTypeAlias or DocumentTypeAlias V6
I am trying to list the children page links of a DocumentType GeneralInformaion. The children are just Textpages. I Have tried numerous things with this Partial View and had no luck. This was easy when we had Razor macro engines because I could use NodeByID() not so easy with V6. The General Information is using umbracoNavihide not to be listed in the Nav.
I have tried
@foreach (var page in Model.Content.Children.Where("NodeTypeAlias == \"GeneralInformation\"").First.Children) {- @page.Name
}
and
@foreach (var group in Model.Content.Descendants("GeneralInformation").First().Children) { foreach(var item in group) {- @item.Name
}
}
Please help this is driving me Krazy!!! Most search examples pull XSLT
Hi keith,
Could you try something like
I got This
Parser Error Message: Expected a "{" but found a "var". Block statements must be enclosed in "{" and "}". You cannot use single-statement control-flow statements in CSHTML pages. For example, the following is not allowed:
Looks like there is a missing closing ")"
Still no luck.
Compiler Error Message: CS0119: 'Umbraco.Web.PublishedContentExtensions.Children(Umbraco.Core.Models.IPublishedContent)' is a 'method', which is not valid in the given context
Source Error:
Line 8:
Line 9:
Line 10: @foreach (var page in Model.Children.Where("NodeTypeAlias == \"GeneralInformation\"").Where("Visible")) Line 11: { Line 12:
Hi Keith,
Have you tried something like this:
Documentation of filtering and lots of more can be found here: http://our.umbraco.org/documentation/reference/querying/DynamicNode/Collections
Hope this helps you.
/Dennis
Hey Mate
If i read u headline and question correct u jumped on the mvc train and what to know how to filter children based on document type. if so then all u need to do is send regular linq to u where statement instead of the "amputated" string version like so
hope that helps :)
That resolved the error and actually list the General Information link. It would be nice to list the children below.
How do i get it to list the textpages below general information?
You iterate over child.Children inside your loop
That works! Thank you!!! At least on my home page. All other templates it comes up blank. I guess it cannot find the route? do you have any suggestions?
I think you just need to make sure your collection is always selecting the children of your rootnode?
For anybody wanting to do the same but inherit the grid layout from the parent node, this works
is working on a reply...