Page 1 of 1

Include a Template in anther Template

Posted: Sat May 30, 2009 12:21 pm
by piero.longhetto
Hi CMSMS's world, i'm newbie to this CMS and i'm using it for building a site. I'm finding it speedy and easy, so i make my compliments to the comunity is supporting it.
I've a question about template.
I look around the forum but i didn't find answers. During the developping i notice that templates have common parts like header, meta and footer. So i tried to create separate templates for that parts and include them in a page specific template (this for a create a better mainting code). Looking around i tried with smarty tag include

Code: Select all

{include file="file:relative/path/to/template.tpl"}
but i notice that there is no way to specify a relative path. if i insert an abosolute path it functions, but if i do that when i go in production site i have to chage all the include and that is not good.
Is there any way to include a template not from a file but from the DB that is where CMSMS stores them or to inclue them from file with a relative path.

Thank you for your attention

Piero Longhetto - Italy

Re: Include a Template in anther Template

Posted: Sat May 30, 2009 3:06 pm
by jmcgin51
Not sure exactly what you're trying to accomplish, but I think you need to look at Global Content Blocks and/or User Defined Tags, if you're trying to create a reusable piece of code.

Re: Include a Template in anther Template

Posted: Sun May 31, 2009 11:29 am
by piero.longhetto
jmcgin51 wrote: Not sure exactly what you're trying to accomplish, but I think you need to look at Global Content Blocks and/or User Defined Tags, if you're trying to create a reusable piece of code.
Thank you for your answer, probably that is the way. I will try with Global Content Block.

Re: Include a Template in anther Template

Posted: Sun May 31, 2009 9:18 pm
by Jeff
If you put in a UDT the relative path (ie echo "file:/modules/template")

then in your template  you can have
{capture assign=relpath}{pathUDT}{/capture}
{include file=$relpath|cat:'template.tpl'}

Re: Include a Template in anther Template

Posted: Wed Jul 22, 2009 4:30 am
by Dr.CSS
imho what your trying to do makes no sense and can lead to larger load times as it has to look all over and make more DB calls to assemble the template... just mho...