-
digitalbutter posted this
We’re building out a large scale bilingual portal using MODx revolution (due to launch in 10 days), and because of the range of different content the site has, we’ve had to create a kind of ‘sub-templating’ strategy for our templates.
The idea is to keep the number of site templates in check - too many templates always leads to a maintenance nightmare - for us as the developers as well as the end user CMS admins.
In this particular site, we have a 3 column layout that goes as follows:

So we need to give CMS admins the ability to choose what sits inside the right column, and in what order it should be showing.
Internally we decided to name the right column blocks as ‘widgets’. We decided that we would be able to build everything we needed with only two templates - one for article folders, and one for articles themselves. Both templates have been assigned three template variables, where each one is intended to load a widget in the right column.
We’ve also created a category in the chunks tree that will contain all available site widgets. If we need new widgets later on, they will be inserted inside this category and will become available for selection for CMS admins.

^ How we’ve organized the elements tree.
We’ve previously used categories for organisational purposes only - but in this case there’s actual functional use (see @SELECT binding below).
The three right widgets template variables have been setup as ‘single select dropdown lists’ where options are drawn dynamically from the right widgets chunks category using an @SELECT binding:
@SELECT name FROM modx_site_htmlsnippets WHERE category = 7
The default value of the TV has been set to @INHERIT, meaning that the choice of right column widgets will cascade down the resource tree, unless a CMS admin decides that they wish to override the configuration for any single resource.
So now that we have assigned those TVs to our two templates, here’s how it renders on the resource edit page:

Lastly, to actually render the widgets inside the right column, we have this block of code inside the template:
<div id=”ls-right-col”>
[[$[[*First]]]]
[[$[[*Second]]]]
[[$[[*Third]]]]
</div>
The MODx parser will evaluate each of those tags as follows (in the example that Top 10 Wines has been chosen):
More to come on this new portal soon =)