Copied to clipboard

Flag this post as spam?

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


  • Marco Lusini 176 posts 1370 karma points
    Oct 05, 2009 @ 13:33
    Marco Lusini
    0

    Dynamically choose a given masterpage at runtime

     

    Would it be possible to dynamically choose a given masterpage at runtime, based on published properties?

    I would like to realize a kind of template inheritance on folder, as in the following (simplified) example.

    Say I have a basic document type with just title and bodytext and a simple site design with the usual header and a left navigation menu.

    This basic doc type can be shown alone (i.e. with a template that simply adds header and left menu) or within a Dossier or a Subsection (or even in a Dossier within a subsection...).

    A Dossier adds a right navigation menu, and a Subsection adds an extra horizontal navigation menu, leading to four different templates:

    • Simple page
      +----------------------------+
      |            head            |
      +------+---------------------+
      |      | Title               |
      |      |                     |
      | left | BodyText            |
      | menu |                     |
      |      |                     |
      |      |                     |
      |      |                     |
      |      |                     |
      +------+---------------------+
      
    • Dossier page
      +----------------------------+
      |            head            |
      +------+-------------+-------+
      |      | Title       |       |
      |      |             |       |
      | left | BodyText    | right |
      | menu |             | menu  |
      |      |             |       |
      |      |             |       |
      |      |             |       |
      |      |             |       |
      +------+-------------+-------+
      
    • Subsection page
      +----------------------------+
      |            head            |
      +------+---------------------+
      |      |  horizontal menu    |
      |      +---------------------+
      | left | Title               |
      | menu |                     |
      |      | BodyText            |
      |      |                     |
      |      |                     |
      |      |                     |
      +------+---------------------+
      
    • Dossier page in a subsection
      +----------------------------+
      |            head            |
      +------+---------------------+
      |      |  horizontal menu    |
      |      +-------------+-------+
      | left | Title       | right |
      | menu |             | menu  |
      |      | BodyText    |       |
      |      |             |       |
      |      |             |       |
      |      |             |       |
      +------+-------------+-------+
      

    The real example is a bit fancier so I can't just put horizontal and right menu in macros that return nothing in the wrong templates, so I end up having 4 templates which share the same content for the main content (Title and BodyText), which is a bit frustrating.

    I would like to be able to define the main content in a simple template that chooses at runtime which parent master page to use.

    Is there a way to achieve this?

     

  • Sjors Pals 617 posts 270 karma points
    Oct 05, 2009 @ 13:57
    Sjors Pals
    0

    I am not sure or this is possible, but i had once something similar where i handled everything in a "wrapper" macro which did check the elements of a page and based on that rendered the page.

     

  • Marco Lusini 176 posts 1370 karma points
    Oct 05, 2009 @ 14:24
    Marco Lusini
    0

    I guess I'd be able to hack something, in the end, but I would prefer a more elegant approach, something emulating the ability of ASP.NET to declare in web.config specific master pages for a given folder...

    Maybe I'm asking too much :)

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies