如何使用 LeBlender 编辑器从 Umbraco Grid 中的嵌套内容中检索值

How to retrieve the value from nested content inside Umbraco Grid using LeBlender editor

我正在尝试从 LeBlender 编辑器中的嵌套内容 属性 编辑器中检索值。

这是我当前的代码:

@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>

@foreach (var item in Model.Items)
    {       

  var listitems = item.GetValue("checkpointlist"); 

  <p>@listitems</p>

}

这输出:

System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent]

我是 C# 和 Umbraco 的新手,但我如何设法输出列表的值/我的嵌套内容?

item.GetValue("checkpointlist") returns IPublishedContent 项目的列表,您可以使用另一个 foreach 循环遍历它。下面的示例输出列表中项目的名称。如果要输出特定的属性,可以将.Name换成.GetPropertyValue("name_of_the_property")

@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
@foreach (var item in Model.Items)
{       
    var listitems = item.GetValue<List<IPublishedContent>>("checkpointlist"); 
    foreach (var listitem in listitems)
    {  
        <p>@listitem.Name</p>
    }
}