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

    I just wanted to get feedback from the community in regards to how many templates you usually end up creating by the time a website is complete. Obviously the answer depends on the size and scope of a website so I will outline the features our site has. (soon to be finished - will post here!)

    Overview: A restaurant lisiting book (think small scale zagat’s) needs to be put online.

    Main features of the site:
    - Restaurants
    - Events
    - Search Listings
    - Articles about food (with archives)

    I’m blown away by the amount of templates I have been forced to use to build this site, in it’s nearly completed state I have 32! I’ve done plenty of MODx sites before that have had many more documents and not needed even 10 templates. With every design I get there are elements to it that require a new template, with no possible workaround given that this client cannot be expected to touch any HTML at all. To give an idea of size, in the end this site will likely have around 2500 docs. Up to 2000 of that number will use the restaurant template.

    The design of the site is very very intricate (a well coded CSS file has grown to almost 5000 lines), and within each page there is ’lots going on’. The main reason for using so many templates is that there are barely any pages using reusable areas that can be coded into templates.

    My question to the community is - what do you think having this many templates show? Have we overdesigned the site, or is this fairly normal? Are we utilising MODx well?

    As a developer my viewpoint is that the designers of this site have not been thinking in a way that lends itself to templating - but to funtime with photoshop... For MODx projects moving forward I’d love if they would make my life easier and make as much reusable as possible.

    Thoughts? Anyone with similar frustrations?

    Site will be live in a few weeks, will post it in the subforum ’your sites’ to get more feedback. Thanks!


      • 4310
      • 2,310 Posts
      I would hope by careful use of TV’s & maybe ManagerManager I would never end up with 32 templates wink
      Regarding the CSS would it be possible to split it into files that reflected the styles needed for each template?
        • 25663 MODX Staff
        • 12,272 Posts
        32 Templates is indeed a maintenance nightmare.
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 25483
          • 741 Posts
          Some times I try to use PHx modifiers to get multiple templates combined into 1 file.

          But you could also make chunks, like {{header}}, {{footer}}, {{sidebar}}, to re-use the parts that are the same in every template.
            with regards,

            Ronald Lokers
            'Front-end developer' @ h2o Media

            • 27708 MODX Staff
            • 2,502 Posts
            Sounds like the designers don’t know what they are doing with regard to interface design. If you have objects that are different in every view you are going to be creating a navigational and cognitive nightmare.

            32 templates is too many. Period.

            You can reduce templates by using PHx as stated but it sounds like the designers either are used to designing static sites or for Joomla/Mambo.

            Typically you might have a main interior template, a seperate template for the index page and landing pages, and a template for the ditto call on the main sub sections and then one template for each of the sub page views.

            In the case of your site I could see using no more than 10-12 templates for your site.

            I have used some php/css magic as well I have used selective ids on the body element that was switched based on the ultimate parent (a little snippet).

            If you have 32 templates and only 12 views you need to think about how you could use snippets/plugins and conditionals like PHx to reduce the templates. In addition the impact said templates have on your end user to have to select the right one. This for me is a major issue. I’d not want my client/end user to have to worry about using the wrong template.

            For your next project (or maybe this one) I’d suggest that you ask here to see if it can be done w/o using a template.
              Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
              • 22840
              • 1,572 Posts
              I’m currently developing a little project of my own which will have as many pages as Modx can handle ( probabley limit it to 4000 until the new version is released) and I’ll be supprised if I go over 8 templates ( at the moment I have 3 and that’s with about 40 layout variations upto now ). You need to put some thought into what is being used more than once and create chunks of TV’s for them.
                • 14090
                • 12 Posts
                Thanks guys, that’s pretty much the response I was expecting and I agree with you all.

                With regards to the large CSS file:

                I beg to differ. More lines don’t equal quality, or any kind of understanding what websites are meant to be. Try to add all of those custom classes in the tinyMCE editor and your client will go nuts scrolling down the endless list of options.

                That was kind of my point, we have coded it well and we can’t get it smaller than 5000 lines - a demonstration again of just how many inconsistencies we’re having to code in order to acheive the design.

                In terms of chunks, yes we are using {{head}}, {{navigation}} etc whenever we can. In fact there’s 132 chunks!... We’re also making pretty extensive use of PHx. Like I said before, the templates are just so strikingly different page to page, those chunks are never outputted in the same positions and so while we do reuse the chunks within each template, they must be organised differently for each of the templates. To give you an idea - we have different article folders, and each folder has an archive view to display all articles within that folder - however - the archives are designing massively different from folder to folder, down to the rowTpl level. Another example - we have a login area for users, sometimes it’s in the left column, on other pages it’s in the right column, and on others - inside the main content column... nightmare, and inconsistent...

                In our experience with MODX and indeed any CMS, we cannot trust a client (especially this one) to stick well to formatting rules even with TinyMCE - they do everything you tell them not to do and then freak out when something breaks (pasting from MSWord for example). Instead we’ve been using PHx to strip tags other than ’img’, ’p’ or ’br’ from the document content TV. This means that anything that is layout related is inside the template, so that there is no chance that the client can break the flow or stlye of the page. No doubt this is another one of the reasons it may seem like we’re using too many templates.

                No doubt we (developers) could have cut down on many things with a little more planning before starting the build of our site (definitely with the CSS file!), but the point of my posting to these forums is to build a case to present to my designers on how NOT to design so as to make things more reusable across the site. As I mentioned previously, we’ve done many MODx sites and this is the first one that has ended in a state like this, recently we did a site with over 100k articles (dating back to 1946 for a small news publication) using 15 templates. FYI we achevied the 100k articles by using a seperate content table as the editors had no need to ever re-edit a majority of their content as it was so old, so it didn’t need to actually be a MODx doc.

                Thanks again for feedback.
                  • 37329
                  • 10 Posts
                  mmm.. 32 indeed seems to much .. In terms of templates: i tend to use 1 template per information type + one or two 'standard webpage' and 'overview' templates. In your case that would be four to six templates. Generally (in modx evo but should work in revo too) I set up al the templates to include one 'filetemplate' snippet that loads one 'unified template file' (for the code and @bobray 's remark on it see: https://forums.modx.com/thread/28499/nested-or-sub-templates?page=2#dis-post-434026 and below )


                  In the unified template file i use PHx or modx revo 'if' snippet to check the template ID and then call either chunks or other template files (via the [[filetemplate&?file=`specific_template_file.htm`]] snippet.


                  another technique that i use is using a TV that is hidden for most of the site authors and that allows me drop in extra html or chunks
                    • 37042
                    • 384 Posts
                    I'd love to see that site and the different layouts. I'd agree that 32 is far too many. I usually end up with about 3. I've a homepage template which is unique and only used once. Then I tend to have an Innerpage Template with

                    Header
                    Navigation Column DIV (using Wayfinder)
                    Content DIV
                    Features DIV (for promo items)
                    Footer

                    That really works for 99% of our work. The actual design on top of each can vary hugely.
                      ...
                      • 37042
                      • 384 Posts
                      Speaking of templates, I've just taken over two large-ish sites which use a single template. One is running Joomla (shoot me now) and the other is using Expression Engine. They both make significant use of 'if' statements to display content based on content IDs etc. Interesting to see how other people and systems use templates.

                      WOuld that be an option for you?
                        ...