I know we can associate different Document Types with the same Template. However, I am wondering if there is any point in doing that. If the template would contain properties from all the different Document Types, it would have to check which of these properties exist or not (depending on the source Document Type).
It makes more sense to me just to associate each Document Type with a different Template and then associate different Content Nodes to the same Document Type.
In general you have a master template that all the others inherit from.
If you need to have a generic set of "header", "seo" etc. templates, I would suggest adding these as compositions. This way you get a model for them, and can create views like views/compostions/header.cshtml, for each of them.
In your template you'd then be able to call @RenderPartial(Model.Content as IHeader, "~/views/compositions/header.cshtml")
Different Document Types with the same Template
I know we can associate different Document Types with the same Template. However, I am wondering if there is any point in doing that. If the template would contain properties from all the different Document Types, it would have to check which of these properties exist or not (depending on the source Document Type).
It makes more sense to me just to associate each Document Type with a different Template and then associate different Content Nodes to the same Document Type.
I 'd appreciate your thoughts on the above.
Hi Ilias,
I would generally say no. I normally have a template specific to the Document Type it is displaying which allows you to use strongly typed models.
This keeps your templates cleaner and easier to maintain :-)
Nik
In general you have a master template that all the others inherit from.
If you need to have a generic set of "header", "seo" etc. templates, I would suggest adding these as compositions. This way you get a model for them, and can create views like views/compostions/header.cshtml, for each of them.
In your template you'd then be able to call @RenderPartial(Model.Content as IHeader, "~/views/compositions/header.cshtml")
That's just one way of structuring your sites :)
is working on a reply...