When developing a site I try to stick to a single template as much as possible, and use smarty logic to add elements that I only want on certain pages or sections. Eg.
{if $page_alias eq "news"}
.....
{/if}
This is because most of my template elements appears on all pages, and if I update the design I don't want to have to update multiple templates to keep them in sync.
So that's fine, but the problem is when I want to use AdvancedContent blocks on some pages but not all pages - even if the AdvancedContent blocks are defined within smarty {if} tags, the AdvancedContent fields are added to every page when editing in Admin, where they are irrelevant to most pages.
It looks like multiple templates might be unavoidable here. So can anyone advise how they manage multiple templates and keep them in sync? Breaking the template up into smaller sub-templates that are then pulled together using includes seems sensible. Global Content Blocks would be one easy way, but I want to give my users permission to edit GCBs and I worry about critical template elements getting messed with. So is there another type of include or method I could use?
How to keep multiple templates in sync - use includes?
Re: How to keep multiple templates in sync - use includes?
I use GCBs to manage common blocks in my templates.. The template only contains the unique content.
But.. I just had a crazy idea... I have a lot of GCBs, and they cause the real global content (that the editor modifies) to get lost. Also, I keep on jumping from block to block, and wish I had them all on one page to edit at once.
What if I created a template called "global", that contains a bunch of content blocks (wysiwyg=false). Create a page called "global" using this template. In this page, put all your global template stuff.. head, javascript, header, menu, footer, sidebar, etc in the separate blocks.
In your templates, you can just use a CGSimpleSmarty call, $cgsimple->get_page_content('global', 'head') instead of the GCB call..
You could even restrict access to the "global" page..
I don't think that there will be much more database overhead to doing this as opposed to GCBs.
But.. I just had a crazy idea... I have a lot of GCBs, and they cause the real global content (that the editor modifies) to get lost. Also, I keep on jumping from block to block, and wish I had them all on one page to edit at once.
What if I created a template called "global", that contains a bunch of content blocks (wysiwyg=false). Create a page called "global" using this template. In this page, put all your global template stuff.. head, javascript, header, menu, footer, sidebar, etc in the separate blocks.
In your templates, you can just use a CGSimpleSmarty call, $cgsimple->get_page_content('global', 'head') instead of the GCB call..
You could even restrict access to the "global" page..
I don't think that there will be much more database overhead to doing this as opposed to GCBs.
Re: How to keep multiple templates in sync - use includes?
Interesting idea, Wishbone.
It wouldn't suit me, as I like to be able to edit my templates in my own editor (using the Template Externalizer module) and Pages can't be managed that way.
I considered bringing in template components using {include file="footer.tpl"}, etc, but after giving the whole issue some more thought I don't think it's worth the trouble. Seeing as I don't have a large number of templates to worry about I think I'll just aim to keep them in sync by updating them individually.
It wouldn't suit me, as I like to be able to edit my templates in my own editor (using the Template Externalizer module) and Pages can't be managed that way.
I considered bringing in template components using {include file="footer.tpl"}, etc, but after giving the whole issue some more thought I don't think it's worth the trouble. Seeing as I don't have a large number of templates to worry about I think I'll just aim to keep them in sync by updating them individually.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: How to keep multiple templates in sync - use includes?
With Smarty3 there's a new feature called 'template inheritance' that would be nice if we could take advantage of:
http://www.golfmsolutions.com/members.html
However, due to CMSMS's implementation we have some challenges to overcome first:
a: Currently CMSMS's content editor has to parse the template using regular expressions to find the content blocks. if the {content} blocks weren't in the template there is no simple mechanism of finding them to provide the appropriate text areas, content areas etc.
There is an idea as to how to work around this problem... just haven't had time to explore it yet.
b: The process of parsing the page template's body before it's head would seem to be in conflict with template inheritance. This feature is important because it allows variables defined in the module call (i.e: $canonical and others that may be defined by users to be used in the head for meta tags, title tags, including javascript etc. We can't break this functionality, so we have to use caution.
c: Implementation. using the smarty {extends} tag would be simple, but specifying the resource would not... so we will have to think about this.
http://www.golfmsolutions.com/members.html
However, due to CMSMS's implementation we have some challenges to overcome first:
a: Currently CMSMS's content editor has to parse the template using regular expressions to find the content blocks. if the {content} blocks weren't in the template there is no simple mechanism of finding them to provide the appropriate text areas, content areas etc.
There is an idea as to how to work around this problem... just haven't had time to explore it yet.
b: The process of parsing the page template's body before it's head would seem to be in conflict with template inheritance. This feature is important because it allows variables defined in the module call (i.e: $canonical and others that may be defined by users to be used in the head for meta tags, title tags, including javascript etc. We can't break this functionality, so we have to use caution.
c: Implementation. using the smarty {extends} tag would be simple, but specifying the resource would not... so we will have to think about this.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.