Triyng для рендеринга узлов из MNTP во вложенном контенте;получение ошибки "... не содержит определения для 'GetPropertyValue'" - PullRequest
0 голосов
/ 27 августа 2018

У меня есть тип документа, который я использую для вложенного содержимого.У него есть свойство MNTP, и у меня возникают проблемы при отображении выбранных узлов.

См. Снимок экрана с типом документа

Я получаю сообщение об ошибке: "Umbraco.Web.ОпубликованныйContentModels.Site_nested_contactGroup 'не содержит определения для' GetPropertyValue '"

Этот код, на мой взгляд:

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 Ответ

0 голосов
/ 27 августа 2018

Вместо этого:

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....
    }   
}

Попробуйте с:

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....
    }   
}
...