Page 1 of 1
include a template from another one
Posted: Thu Mar 10, 2005 7:11 pm
by saltydog
Is there any way to include a template into another one?
My problem is that I have 7 sections in my CMS. These sections should have the same template, but different CSSs. So, instead of making 7 copies of the same template (with different names) and link the 7 CSSs to them, I thought to maintain just one template, while in the other six just put a reference to it (something like 'include...'). This is to avoid that if I have to edit the template, I should replicate the edit 7 times...
Re: include a template from another one
Posted: Thu Mar 10, 2005 9:00 pm
by 100rk
saltydog wrote:
These sections should have the same template, but different CSSs.
'Sections should have the same template...' You mean 'sections can be a part of the same template', don't You? In this case You have to ask Yourself, why You don't describe Your different 'sections of ONE template' in different CSS styles, all of them attached to Your complex template. Do You know, what I mean?

BRIEFLY: template can have attached more then once CSS style and every of attached CSS styles can describe different part of Your template.
OR - if I am wrong and You mean ordinary Smarty tags
for logical dividing Your template into smaller parts, so this thing is not applicable here (for now). But You know

there is no rule You can not write Your own module or plugin, which will use functions from classes 'TemplateOperations' and 'Template' (/lib/classes/class.template.inc.php) and also will redefine functions 'ContentTemplate()' and/or 'ContentPrerender()' inherited from class 'CMSModule' - but question is 'if it is necessary'. It is not easy as I briefly wrote here, because You have think about it in more complex way: I mean don't forget about tags like {title}, {stylesheet} and also about other parameters of template like encoding or 'active flag'.

An another thing: in this time is in CMSMS no HTML syntax control for templates (like PHP syntax control for user defined tags), but nobody knows if it will be added or not in future - if You will create partial templates (by example without , , ...etc tags), future complex HTML syntax control can be ugly surprise for You.
Re: include a template from another one
Posted: Fri Mar 11, 2005 8:27 am
by saltydog
Thank you. Very interesting reply from which I will take advantage, for sure.
But let my try to explain my (simple) problem. The site has a menu with 7 main entries (let's call them rooms). The site uses all the same template for every room, except for the "thebody" style, which is different.
Now, I would like the authors, when they upload an article, are able to link their article with the correct style and the simplest way to let them do this is to have 7 templates (tpl_room1, tpl_room2, etc) from which they easily select in the combobox when uploading the article.
Re: include a template from another one
Posted: Fri Mar 11, 2005 9:02 am
by 100rk
Oh, I see I wasn't understand Your needs...
Answer is: Yes, in this time You have to make 7 different templates (or only with different names)

but for make this thing easiest (or comfortable) as possible for You, You can create one CSS stylesheet with common CSS attributes for all Your templates (if there are any common values) and special CSS settings for every template You can write down into textarea CSS in 'template edit' page, because tag {stylesheet} will include both CSS styles - 'main' and attached also. In this case there will be 7 templates with its own special CSS settings and only 1CSS style linked to every of those templates. AND - I hope wysiwyg editor will attach all proper CSS settings which You use in every template (and attached CSS) so when user change template in dropdown, look of wysiwyg content in editor will be properly changed.
I mean: user can change template (not template CSS) in during creating/editing content page and You have to make peace with this fact.