I’m trying to get my head around templates, as compared to PHP-Nuke based CMS’s I have used in the past, which are site-wide, although you can turn on/off the left and right columns.
So in MODx, can a page be linked to a different template than the main one?
I plan to use a standard 2-column template with header and footer, with an overall centered width of 760 pixels. However, on a couple of pages with lists I want to remove the right column and just use the complete width for content.
So my question is: Can I have two templates to do this? Or is there another way?
Thanks,
Peter
-
MODX Staff
- 12,272 Posts
You could have 200 templates if you liked. There are other ways to accomplish what you’re looking to do, but a couple of templates is the fastest and most intuitive way to get there. Check out Template Variables for your sidebar content.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
☆ A M B ☆
- 24,524 Posts
You can have all the templates you want. Each document can be assigned to a different template. See image below.
Since most of the template will be the same, break out the header (masthead) and footer into chunks and use the chunks in both templates.
However, I would be inclined to do this a bit differently. Since you only want a few pages to use basically the same template except for losing the sidebar, I would put the entire sidebar into a TV with the common HTML sidebar structure as its default value. Replace your sidebar HTML in the template with the TV’s tags. Then for the few pages you want without it, edit the TV for those documents and delete the default value.
You could also add a class to the <body> (<body class="fullwide">) tag using a snippet to add the class only on those few pages, and do any added styling for the pages with that class. The snippet would compare the current document’s ID against an array of IDs and add the class if it matches.