Unable to retrieve field values of Nested Content in separate Partials (Umbraco 8)
I had an Umbraco 7 setup that allowed me to render Nested Content with a foreach loop, pulling in separate partial files to render the information, mimicking the macros/"widget" customization on older versions of Umbraco. On a View page, I would have the following:
but this code doesn't appear to translate to Umbraco 8. The @Html.Partial(viewPath, item); section throws an error because of the 'item'. I can remove 'item' from the code and it pulls the Partial in, but anything within that partial tries to read fields on the main page instead of the fields of the Nested Content element, so it renders nothing. There doesn't seem to be a way to link the Nested Content to the Partial code.
Is there something I can do to get Nested Content working how I want?
Unable to retrieve field values of Nested Content in separate Partials (Umbraco 8)
I had an Umbraco 7 setup that allowed me to render Nested Content with a foreach loop, pulling in separate partial files to render the information, mimicking the macros/"widget" customization on older versions of Umbraco. On a View page, I would have the following:
but this code doesn't appear to translate to Umbraco 8. The
@Html.Partial(viewPath, item);
section throws an error because of the 'item'. I can remove 'item' from the code and it pulls the Partial in, but anything within that partial tries to read fields on the main page instead of the fields of the Nested Content element, so it renders nothing. There doesn't seem to be a way to link the Nested Content to the Partial code.Is there something I can do to get Nested Content working how I want?
Sounds like your views are expecting a different model to the one you are passing in.
Should have this in your partial view:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
See this post for more info: https://our.umbraco.com/forum/templates-partial-views-and-macros/97248-nested-content-in-separate-partials
I think that might have fixed the issue. Thanks!
is working on a reply...