We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1764
    • 680 Posts
    I don’t realy see any simple way to create page templates at this point. To me it seems like the typical site would want to have one ovelall site template to define the look and feel of the site and multiple "page templates" for the layout of the content for that specific page.

    For instance, when we make the conversion for our college’s site we’ll want to have a "page template" for free form content. We’ll want to have another one for our athlete bio pages. These pages will be a set of TVs like Name, photo, sport, age, height, weight, home town, etc. So we’ll need a whole other template for this sort of page. But I don’t want to create a whole new site template just to define the different content. But I need a whole new template so I can associate the bio-specific TVs to those pages.

    Here are some of the existing solutions as to how to handle this without duplicating whole templates:

    Create {{Header}} and {{Footer}} chunks. Ah, the good old days tongue This works but I’m sure we can all agree that we’d rather leave the whole header/footer template thing in the past where it belongs.

    Create a TV to select the page template. The problem with this is you have only one template so every TV get’s associated with every page. Not an acceptable solution.

    Use a site template chunk and page template TV combination. That way you can create as many templates as you want for TV orginization reasons and just drop a {{Template}} chunk in it. And then you can choose the page template via a TV. This works pretty well but the downside is that you have to keep the Template and the Page Template TV in sync or it just doesn’t work.

    Page Template placeholder via snippet This is what I’m doing now. You can write a simple snippet to just set a placeholder from a passed property and then output the template. In the template you use a placeholder for the page template. Then in each new template you just call [[TemplateSnippet?page_template=bio]]. This takes care of it pretty well but is far from intuitive for a beginner.

    If we add snippet-like properties to the templates then we could set placeholders in the properties. This would be much simpler than the snippet route but I think we can do better still.

    Any ideas?
      • 25663 MODX Staff
      • 12,272 Posts
      Even with 0.9.5 I don’t see this quandry getting better. As it stands now, even have [[$template]] to work with, I don’t see how it will make creating templates easier. I’m afraid we’re almost going to have to go to a templating language to handle things like repeating tables, repeating sections, etc... hrm...
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me