0
votes

I have document type that I use for Nested Content. It has an MNTP property, and I have problems rendering the picked nodes.

See screenshot of document type

I am getting the error: "'Umbraco.Web.PublishedContentModels.Site_nested_contactGroup' does not contain a definition for 'GetPropertyValue'"

This code is in my view:

var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}
1
Hi Niels - try the following code: var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons"); and in your foreach, try var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");Mikkel
Thanks - that solved it. :) If you create an answer, I will mark it as an answer.niels.joergensen
Great, I've posted the answer :)Mikkel

1 Answers

0
votes

Instead of this:

var items = CurrentPage.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}

Try with:

var items = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("contactpersons");
foreach(var item in items)
{
    var persons = item.GetPropertyValue<IEnumerable<IPublishedContent>>("persons");
    <h2>@Umbraco.Field(item, "headline")</h2>
    foreach (string contactperson in persons)
    {
        .... render contactperson....
    }   
}