We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26083
    • 32 Posts
    Hi,

    I have different kind of pages (ayurvedic school):


    • Some page will describes trainings
    • Some pages will describes Practicionners[b]
    • Some pages will describes [b]Teachers[b]
    • ...
    • Some pages will display formatted result list of a Ditto call

    So I found that having different templates for each type of content is very useful. So I can attach different TV. I created the following templates:


    • [b]trainings - Display training content with specifics TV (date of the training, price, diplome, ...)
    • practicioner - Display practiconner content with specifics TV (name, phone, picture, website, ....) ...)
    • ...
    • Default - To display ditto result (they are formatted using their own chunk

    I’am very happy with this system, but I always need to copy/paste from an initial template (the default one). And in fact very few changes between the template.

    What I do want, is to be able to have multiple template because it give me the possibility to assign different TV for different type of content. Also it allows me to format them. But it will be nice to maintain only one physical template, something such as :

    Common part of the template
    <div id="summry">
    if (template=="training") insert training-summary-chunk-language
    else if (template=="practicioner") insert practicioner-summary-chunk-language
    else ...
    </
    Common part of the template
    



    Any ideas for that ?

    Modx 0.9.5 beta5



      • 16429
      • 254 Posts
      I usually cut the template in pieces I reuse and pieces template-dependant.

      Using chunks you can have, let’s say, the same header and footer on every page and you have only 1 place to edit if you want to, in the chunks section.
      I do this because, like you, I’ve many templates for different TVs but the templates aren’t so different.

      BTW, why you copy/paste? There’s a comfortable "Dupe" function grin
        kudo
        www.kudolink.com - webdesign (surprised?)

        [img]http://www.kudolink.com/kudolinkcom.png[/img] [sup]proudly uses[/sup] [img]http://www.kudolink.com/modx.png[/img]
        • 6726
        • 7,075 Posts
        You can also greatly reduce the number of template using PHx, just like you want, thanks to its conditionnal operators smiley
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l&#39;outil id
          • 14412
          • 74 Posts
          Hey,

          You already got a relevant answer, but just thought you might enjoy seeing an actual example using chunks. Just mix-n-match them according to your needs, creating different templates:

          Example template 1:

          {{TPL_HEAD}}
          {{TPL_SCRIPT_1COL}}
          {{TPL_CSS}}
          {{TPL_HEADER_AND_MENU}}
          {{TPL_CONTENT_1COL}}
          {{TPL_LINKS_SUBMENUS}}
          {{TPL_FOOTER}}

          Example template 2:
          {{TPL_HEAD}}
          {{TPL_HEADER_AND_MENU}}
          {{TPL_CONTENT_2COL}}
          {{TPL_LINKS_TAGS}}
          {{TPL_FOOTER}}

          Both examples share the same <head> section, banner and main menus, and footer, but are quite different:


          • Ex. 1 has custom js scripts and css properties.
          • Ex. 2’s content area is divided in 2 columns and instead of links on the sidebar has tags.

          Enjoy, JP
            Got Music? Try XSPFjukebox - Skinnable MODx Media Player