Copied to clipboard

Flag this post as spam?

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


  • Ilias 11 posts 81 karma points
    Mar 12, 2018 @ 11:50
    Ilias
    0

    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.

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Mar 12, 2018 @ 11:54
    Nik
    0

    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

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Mar 12, 2018 @ 12:18
    Søren Gregersen
    0

    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 :)

Please Sign in or register to post replies

Write your reply to:

Draft