Smarty, like the Template Toolkit (Perl), apparently follows a different approach than what I mean here.
Concerning my first idea, for the modx contributor our template Y is in the end just another ’static’ template that has its set of tvs to fill up like any modx template. The fact that Y extends X is solely the administrator affair.
The second idea doesn’t imply logic within the template neither, sorry for getting me wrong. I mean just templates where you can choose between alternative components at certain positions. But it is not the template that defines these alternatives, it is rather the template variable for which there could exist a special type "subtemplate".
An example: A template variable "heading" for which you could define two subtemplates:
- simple: <h1>[*longtitle*]</h1>
- extra_info: <h1>[*longtitle*]</h1><div class="small">by [*author*] published on [*publishedon*] / Tags: [*tags*]
So, when a template using tv "heading" is selected for a document, another option-input field could appear below the template selection:
This way you can specify for any specific document whether or not to display author, published date and tags, and only if yes, the respective fields are shown in the doc form. You don’t need a "show extra info" toggle tv, which would require the additional fields to be shown no matter if there are used.
As a final note, it is clear that those template extensions, if implemented, should be applied with caution lest the presentation of the site as a whole get heterogeneous, even confusing. I won’t deny this danger.
Thanks,
agilero.