Extracting nested content value from surface controller
Hello, I'm trying to access some data from a SurfaceController, but I'm having some issues. This is how it looks right now:
public class PublicationsController : SurfaceController
{
[HttpPost]
public ActionResult GetAll()
{
var page = Umbraco.Content(Guid.Parse(/*guid*/));
}
}
Not sure if that's a good start, but I can access the properties to some extent. I have a nested content property that holds what I need to access. I can manage to get the alias of this nested content property, however I need to extract everything inside it so I can serialize this into json. Right now this nested content property holds different folders, with media items inside of these folders. Any pointers?
If you know the property alias, your method could be:
var page = Umbraco.Content(Guid.Parse(/*guid*/));
var nested = page.Value<IEnumerable<IPublishedElement>>("myPropertyAlias");
return Content("{nested?.Count() ?? 0} elements found");
Extracting nested content value from surface controller
Hello, I'm trying to access some data from a SurfaceController, but I'm having some issues. This is how it looks right now:
Not sure if that's a good start, but I can access the properties to some extent. I have a nested content property that holds what I need to access. I can manage to get the alias of this nested content property, however I need to extract everything inside it so I can serialize this into json. Right now this nested content property holds different folders, with media items inside of these folders. Any pointers?
Hi,
Nested content return a single or multiple instances of IPublishedElement
https://our.umbraco.com/Documentation/Fundamentals/Backoffice/property-editors/built-in-property-editors/Nested-Content/
If you know the property alias, your method could be:
Well now I feel silly .. I had forgotten a "using" statement to access it like that. Thank you!
is working on a reply...