Hi,
I’ve just completed my first serious MODx site.
http://www.verdantconsulting.co.uk
Through this project I altered my approach regarding Templates/Chunks and TVs and would appreciate some feedback as I plan my next development.
When learning MODx using some of the workthroughs I gained the impression that everything ’passed the buck’ to something else and it seemed for a while that finding the code that actually did some real work was quite difficult (usually a chunk called from another chunk (repeat) called from a template).
I quickly realised that this was abstraction (probably) with responsibility for action moved into "one thing well" chunks. And another vital insight (which is perhaps obvious) is to ensure no code appears in the Content of a page. So e.g. when creating Accordions or Tabs the Content comes from TVs - rather than try to have jQuery ’HTML stuff’ mixed up with the text the user will manipulate.
So, I started the project with a ’Generic Approach’. A GenericPage template which contained Generic-Header/LeftSidebar/RightSidebar/Footer Chunks.
Plan being to have a limited number of Templates each related to the page structure. So there may be 12-20 pages but only 4-5 Templates
But I found that most pages were different enough to need their own template so instead of a list of templates like this
GenericT(emplate), SingleLeftSidebarT, SingleRightSidebarT, AccordionContentT, DittoContentT etc.
I instead have
HomePageT, NewsPageT, AboutUsT, ContactT, etc
And then I have specific Page Chunks embedded into what are actually fairly standard page Templates (as I ended up keeping the structure of header/sidebars/footers constant. E.g.
{{GenericHeader}} {{GenericSidebar-Left}}
{{HomePageContent}}
{{GenericSidebar-Right}} {{GenericFooter}}
{{GenericHeader}} {{GenericSidebar-Left}}
{{CaseStudyContent}}
{{GenericSidebar-Right}} {{GenericFooter}}
So, every Page Template only has {{OnePageSpecificChunk}} that is unique.
And a final consideration. If a Page requires a TV then it requires a specific Page to assign that TV to, with the ’Generic’ approach this may not be do-able (but I’m not sure about that).
So, the question or thought for the day. Should each page have its own namedTemplate (with the exception of Container stuff such as Articles/Blogs). Or should each PageStructureType have a Template (GenericApproach). Mindful of the TV to Template issue.
I think the Generic approach perhaps has the advantage that should I wish to change the entire look of the site I need only change a few Generic Templates rather than edit lots of PageTemplates most of which are identical apart from the {{OnePageSpecificChunk}}. But as I found there were enough variations between pages that it wasn’t practical.
Cheers
Parthian