Strongly Typed Model for Composition and Child Node
We're creating a baseline site and I'd like to find a way of creating re-usable page elements, e.g. a Call to Action which can be used either as a composition on one type of page where it's static or as a child of another type of page so it can be sorted.
I'm aware I could use the grid for the sorting, but wondered if there is a way of building the partial view so it can be used for both.
If I reference the model using View Page @inherits UmbracoViewPage
If I reference the interface @inherits Umbraco.Web.Mvc.UmbracoViewPage
Your code examples don't appear to have come through properly, but I'm assuming you had something like this:
@inherits UmbracoViewPage<IMyComposition>
These two variations?
@inherits UmbracoViewPage<MyComposition>
I think you should be able to use the second version to handle both composition behaviour and full page rendering, although you might need to do a cast in order to get it to work. This is because MyComposition will inherit from IMyComposition which might allow you to pass between the two.
Strongly Typed Model for Composition and Child Node
We're creating a baseline site and I'd like to find a way of creating re-usable page elements, e.g. a Call to Action which can be used either as a composition on one type of page where it's static or as a child of another type of page so it can be sorted.
I'm aware I could use the grid for the sorting, but wondered if there is a way of building the partial view so it can be used for both.
If I reference the model using View Page @inherits UmbracoViewPage
If I reference the interface @inherits Umbraco.Web.Mvc.UmbracoViewPage
Is there a way I can do both?
Hey Kerry,
Your code examples don't appear to have come through properly, but I'm assuming you had something like this:
These two variations?
I think you should be able to use the second version to handle both composition behaviour and full page rendering, although you might need to do a cast in order to get it to work. This is because
MyComposition
will inherit fromIMyComposition
which might allow you to pass between the two.I've not tested this so it's just a theory.
Nik
is working on a reply...