I'm trying to retrieve the values from a nested content property editor inside a LeBlender Editor.
This is my current code:
@inherits UmbracoViewPage<Lecoati.LeBlender.Extension.Models.LeBlenderModel>
@foreach (var item in Model.Items)
{
var listitems = item.GetValue("checkpointlist");
<p>@listitems</p>
}
This outputs:
System.Collections.Generic.List`1[Umbraco.Core.Models.IPublishedContent]
I'm very new to C# and Umbraco, but how do I manage to output the value of the list / my nested content?
item.GetValue("checkpointlist")
returns a list of IPublishedContent items, you can loop through this with another foreach loop. The example belows outputs the name of the items in the list. If you want to output a specific property, you can replace .Name
by .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>
}
}