Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Glenn Franquet 15 posts 46 karma points
    Aug 18, 2015 @ 16:44
    Glenn Franquet
    0

    Multiple levels of views

    In Umbraco you can have multiple levels of views like for example following structure

    see image

    Pages created with templates under the "2 kolommen" template are from different document types but have the same parent document type.

    In Layout I'm using

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<IMasterModel>
    

    In "2 kolommen" I want to use something like

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<MasterModel<ParentDocumentType>>
    

    The reason for that is that I want to have access to Model.Content to pass this to a partial view to display a banner.

    But when I go to a news page for example I get an error message that looks like the following:

    The model item passed into the dictionary is of type 'UmbracoEntities.Domain.MasterModel`1[.UmbracoEntities.Domain.Generated.News]', but this dictionary requires a model item of type 'UmbracoEntities.Domain.MasterModel`1[UmbracoEntities.Domain.Generated.ParentDocumentType]'.
    

    Is it possible to work around this error message and be able to use the Model.Content? Or are there maybe other options to be able to pass the content to the Parial View of the banner?

  • Glenn Franquet 15 posts 46 karma points
    Aug 19, 2015 @ 10:37
    Glenn Franquet
    0

    I found a workaround by using also on the "2 kolommen" the IMasterModel.

    This still means of course that I'm not able to access Model.Content on this view. But it seems that I didn't need to pass Model.Content to the partial view to display the banner. I just could use the following on the Banner partial view:

    @inherits Umbraco.Web.Mvc.UmbracoViewPage<UmbracoEntities.Domain.Generated.Master>
    

    But I'm still wondering what I have to do in case that I need some elements of Model.Content on the "2 kolommen" view. My guess is that I need to extend the IMasterModel with this properties like I had to do for the "Layout" view. Or are there still other options?

Please Sign in or register to post replies

Write your reply to:

Draft