0
votes

I am currently trying to output data from the new Multinode Treepicker in Umbraco 7.6.4 here is my current setup and code:

Doctype

Screenshot of Doctype

Content Node with 'Page' Doctype Screenshot of content node

Code to output the names of the selected nodes:

@{
    IPublishedContent typedContentPicker = Model.Content.GetPropertyValue<IPublishedContent>("sections");
    if (typedContentPicker != null)
    {
        <p>@typedContentPicker.Name</p>                                                
    } 
}

This I took from the official Umbraco Documentation and adapted it to my project. This code is in a template with the 'page' doctype.

Currently the above code does not output anything to my page, I am expecting to see a list of nodes displayed on the page, can anyone see what the issue is or where I am going wrong?

1

1 Answers

1
votes

Dumb moment, I was looking at the documentation for a content picker and not a multi-node tree picker!

Correct code is:

@{
var typedMultiNodeTreePicker = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("sections");
    foreach (var item in typedMultiNodeTreePicker)
    {
        <p>@item.Name</p>
    }
}