We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7869
    • 118 Posts
    I’ve just run into a problem that I never thought about before (probably because I’m NOT a programmer so it’s not in my skillset to forsee changes in the future).

    I’ve made a site with about 200 pages that has a 4-level hierarchy structure: HomePage, Main Categories, Sub Categories, and Products.

    Each level of the hierarchy has it’s own template which means my site uses four templates. Would it have been possible for me to build my site using one template? How? My main reason for asking this is because I wanted to "update" my website with a new look and I realize that not only do I have to make four versions of the new template, I also have to go through all 200 pages and assign them their new template. Not good. Are there any tutorials for something like this?
      -Dorian
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      The Doc Manager module will save you hours and hours of time (look under the Modules tab in the manager). It has an option in there to let you change templates across multiple pages.

      Secondly, 4 templates is manageable... I worry more about the sites that have 10 or 20 templates. It’s possible you could consolidate your templates, yes... maybe through use of Chunks and Template Variables, you could add or subtract specialty parts of your "core" template and get by with a single template, but don’t hurt yourself. Doc Manager should make 4 templates a very workable number.
        • 3749
        • 24,544 Posts
        It’s quite possible that you could use a single template for all your pages. Many MODx sites have just one template. It’s not uncommon, though, to have a separate template for "product" pages.
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 5340
          • 1,624 Posts
          HI,

          Not sure if it will help but here is how I do it:

          1. Install IncludeTemplate Snippet
          2. create a file(template01.html) in your templates/site like:

          [[includeTemplate? &tpl=`site/head.html`]]
          
          <body>
          
          [!includeTemplate? &tpl=`site/top.html`!]
          
          <div id="homeContent">
          [*content*]
          <div>
          
          <div id="homeBottomLinks">
          [*homeBottomLinks*]
          <div>
          
          [[includeTemplate? &tpl=`site/facelift.html`]]
          </body>
          </html>


          3. Create a template in modx and named what you want. Just enter [[includeTemplate? &tpl=`site/template01.html`]]

          4. If you want to control the templates that new documents are created with, use Template Rules Plugin. See signature.

          I personally like to have my template separate from any coding. Maybe in some cases I would recommend the use of Phx.




            • 9207 ☆ A M B ☆
            • 2,475 Posts
            [[includeTemplate? &tpl=`site/head.html`]]


            Why not do this with a chunk?
              • 5340
              • 1,624 Posts
              but I like files :’(

              ...and I never mastered the chunk@file technic smiley