We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22839
    • 7 Posts
    This sounds (even for me) a very basic question. However I must admit that I’m a little confused about how should I do it.
    I have a simple site with 4 pages. I made the home page "by the rules" of MODx but now I have some questions;


    Do I need to create new templates for the remaining pages? (seems not the best solution) or, should I edit the home page template and create a new document/s and assign to it?

    Thanks in advance and sorry for my poor English tongue
      • 20413
      • 2,877 Posts
      Make 4 new docs and assign them to your one template to start with! Then create new templates if you want
      really different scripts/layouts/code for some doc.

      The way modx works is - all the ways work. You can use a file as template, you can make your own tv to call
      inside your template as every doc get called by *content* built-in tv.
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 22839
        • 7 Posts
        Thanks a lot for your reply wink
        I guess I will make different templates for each page until I discover what the best practices to work with MODx are.
          • 20413
          • 2,877 Posts
          On my first modx page I used 5 templates while looking at that page today it needed one.

          Some snippets e.g. sitemap snippet can let you exclude all docs assigned to certain templates.
          But basically with your own tvs you dont need to make a whole lot of templates.

          For instance I have a [*headContent*] in my template so I can load scripts for a doc right away.
          Then there is PHx... but thats later! wink
            @hawproductions | http://mrhaw.com/

            Infograph: MODX Advanced Install in 7 steps:
            http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

            Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
            http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • 3749
            • 24,544 Posts
            I generally try to see if I can get by with one template and create special purpose templates only if I really need them. As mrhaw suggested, when I look at older sites of mine, I see that I should have used fewer templates.

            The key is to put things in the template only if you want them on *every* page.

            Some sites do require multiple templates, but creating a new template for each page is definitely practice you will be sorry about later.

              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
              • 9207 ☆ A M B ☆
              • 2,475 Posts
              Paulo-

              Maybe you’re used to other CMS’s... in MODx each page has a template. In some other CMS’s, a template has one or more pages. Personally, I find it much easier to take a page and choose how to display it by choosing which template is uses. You can make a simple template like this:
              <html>
              <head>
              <title>[*pagetitle*]</title>
              <body>
              [*content*]
              </body>
              


              And all of your pages could use that. It’s not very exciting, but it’d work.
              Bob is right... don’t make a bunch of templates when you could be making content. It just defeats the purpose.

              Have a look at the Wiki articles:
              http://wiki.modxcms.com/index.php/Placeholders_used_by_MODx_Pages_and_Templates
              http://wiki.modxcms.com/index.php/Beginner%27s_Guide_to_MODx
                • 7231
                • 4,205 Posts
                In general you can use a single or very few templates, but there is nothing wrong with multiple templates. If the layout is drastically different on each page then multiple templates may be best. It is up to you and what you feel better working with.

                don’t make a bunch of templates when you could be making content.
                Not sure I agree, layout and content should be kept isolated. If you mean use TVs of other parameters to manage layout I agree, but I can’t say that it is a good idea to put layout in the [*content*] field.

                I like to use ’if’ snippets to do simple layout logic based on document properties. Stuff like ’if a container output x layout’ or ’if parent is x output y’. These are very light and if you can use a documentObject parameter as a trigger very low overhead.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  dev_cw, I totally agree with you. Sorry... my post was confusing (late night), so I guess it sounded like I was proposing something else than what you shared.

                  As a rule, any html that affects the layout should not live in the content. Anything that affects the HOW of something looks is not content. Content is all about the WHAT. Therefore CSS never qualifies as "content". One example of how to think of this comes with images... some images (e.g. background images, rounded corners) only affect how data is displayed, so they should therefore live in a template away from the content. But if the content is an article about Richard Nixon, and you have a jpg of the former president, that probably qualifies as content, so it should probably live in the content.
                    • 23299
                    • 1,161 Posts
                    I guess the other thing to consider is that if your site needs many different templates it may indicate that your overall design esthetic lacks focus. I find the best sites have one main design focus and that all the content fits within that design.

                    Its also hard to resist adding every cool MODx snippet, javascript library and high eye-candy app out there. But I really like how flexible MODx is with respect to using different tempaltes. Sometimes its just easier to use a new modified template to get something to work the way you want it to.