Interesting requirement, let's see if someone would be able to come up with a solution :)
Hi, I am not sure what you want to achieve - how would you want your view to look like? Like some listing page that lists an image, heading and some intro text? Perhaps you can inherit from the same interface in all pages and map the interface to view model. Than you can use the same block to render the list of view models. Something like this:
@foreach (var teaser in @Model.Teasers)
{
Html.RenderPartial("Blocks/Teaser", @teaser);
}
Sorry if this is not what you had in mind, perhaps you can give some more info?
Hey Erik,
You can iterate over them and render them using Html.RenderContentData(child, false).
RenderContentData will then render them using the same template resolving mechanism as for content areas, meaning you could have a partial view for each type in shared.
Hi and thanks for the answers!
Didn't get any notifications so I digged up my own solution that ended up like this:
@foreach (var child in EPiServer.DataFactory.Instance.GetChildren(Model.ContentLink.ToPageReference()))
{
Html.RenderPartial(String.Format("~/Views/{0}/Index.cshtml", child.GetType().Name.Replace("Page", "")), child, ViewData);
}
I tried the RenderContentData first, but it never worked, guess I put my views in the wrong place, gonna give it another try!
I tried Joels approach again, and it worked. Supposed that it was an easy task if you only knew how. :)
Hi,
this is my first EPi7 MVC project, so I'm not sure if this question is stupid or not.. :)
I have a page with a few children. The children of the page is of various page types.
Is there a way to render the children with their own view on this page?