Hello dev-people
My designer had an interesting suggestion, which I thought I'd run through you. When we built up site we often are in the situation where we have an overall design of the page and then the content-area can have several looks, 3 columns, 2 columns and some static/news etc. Doing 3-4 complete templates works but it's not nice when we then have to tweek design later, having to make the same changes 3-4 places. What we talked about was some way of having a template inheriting from another so that it replaces the {content} tag of the "mother"-template, and in turn replaces it's own {content} tag with the actual content. As far as I can see there's 2 was of doing this, the easy and the hard...
1. Having a field in template editing providing a list of the other templates defining simply a template to include when the present one it selected. This brings up some questions as to multiple levels and the resulting possibility of recursion. Not nice. Could be overcome by limiting to 1 level of inheritance
2. Doing an actual hierarchy (I love spellchecking in FireFox) of templates, like in pages, allowing subtemplates to include mother-templates without the fear of recursion.
What do you think? I don't think it's that difficult to do, it won't make the process more complex as you can easily ignore the "mothertemplate" option... But it will make templating very powerful.
Some thought should go into the matter of stylesheet-inclusiong I guess, but that should be solvable
Regards
Silmarillion/Morten
Template inheritance?
- Silmarillion
- Dev Team Member
- Posts: 483
- Joined: Sun Jan 02, 2005 9:10 pm
- Location: Denmark
Re: Template inheritance?
you mean something like this?....
a cmsms template:
{global_content name='template-meta'}
{global_content name='template-header'}
{content}
{global_content name='template-footer'}
another cmsms template:
{global_content name='template-meta'}
{global_content name='template-header'}
{content}
{news}
{global_content name='template-footer'}
where 'template-meta' contains everything from doctype to ; 'template-header' contains to just before ; and 'template-footer' contains everything below div#main's closing tag to
another option is smarty's own {include} function.
http://smarty.php.net/manual/en/languag ... nclude.php
a cmsms template:
{global_content name='template-meta'}
{global_content name='template-header'}
{content}
{global_content name='template-footer'}
another cmsms template:
{global_content name='template-meta'}
{global_content name='template-header'}
{content}
{news}
{global_content name='template-footer'}
where 'template-meta' contains everything from doctype to ; 'template-header' contains to just before ; and 'template-footer' contains everything below div#main's closing tag to
another option is smarty's own {include} function.
http://smarty.php.net/manual/en/languag ... nclude.php
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
- Silmarillion
- Dev Team Member
- Posts: 483
- Joined: Sun Jan 02, 2005 9:10 pm
- Location: Denmark
Re: Template inheritance?
Hi Kermit
You are right, the feature I was seeking could be implemented using global content as you show, but could be built into template system as well... I think it would be more elegant...
Sil.
You are right, the feature I was seeking could be implemented using global content as you show, but could be built into template system as well... I think it would be more elegant...
Sil.
Re: Template inheritance?
i dunno.. adding more clutter to the admin panel that most won't need or use might cause it to lose some of it's "simple-ness" -- but if someone wants to split up templates into smaller chunks, they can use gcb's or maybe smarty's {include}Silmarillion wrote: You are right, the feature I was seeking could be implemented using global content as you show, but could be built into template system as well... I think it would be more elegant...
there are cms packages that use multiple templates to create a 'theme' but those generally also have more features 'out of the box' than a core cmsms package (drupal, xaraya, wordpress, textpattern, etc); and it's also a bit more complicated to make a 'theme' in those than in cmsms.
cmsms does use multiple templates, they are just part of whatever module requires them (news, menus, third-party modules, etc) instead of being part of a 'theme'. i like this approach better.
___
another option for you might be to use a unique class (in your template) on your pagewrapper or content container (such as a $page_alias); so you can use css alone to layout a page differently without needing multiple templates.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Re: Template inheritance?
Hello Kermit!
I actually was looking for the same feature as Silmarillion. I think I could easily live with your proposal, if there were a way to have the name of this global template in a variable that I could use for the whole site. Then I have the possibility to apply an other "master-template" without having to change the name in every single content-template.
Is there a location where I could save such a user-defined variable and then read it with the global_content parameter?
{global_content name=$mastertemplate_top}
I hope you understand what I'm trying to explain ...
Greetings,
Robert
I actually was looking for the same feature as Silmarillion. I think I could easily live with your proposal, if there were a way to have the name of this global template in a variable that I could use for the whole site. Then I have the possibility to apply an other "master-template" without having to change the name in every single content-template.
Is there a location where I could save such a user-defined variable and then read it with the global_content parameter?
{global_content name=$mastertemplate_top}
I hope you understand what I'm trying to explain ...

Greetings,
Robert
Re: Template inheritance?
Speaking of Templates.... I don't think this is (completely) related to Sil's original post but I thought I'd mention it anyways.
It would be nice to be able to access certain content blocks in Modules, for example I have a site that has pages where there's a sidebar and some pages in which there's none, I would like for example to be able to set a default page for News or Blogs, let's say the template with the sidebar and then be able to edit the sidebar area for a particular Entry. What do you guys think?
It would be nice to be able to access certain content blocks in Modules, for example I have a site that has pages where there's a sidebar and some pages in which there's none, I would like for example to be able to set a default page for News or Blogs, let's say the template with the sidebar and then be able to edit the sidebar area for a particular Entry. What do you guys think?