Include a Template in anther Template

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
piero.longhetto
New Member
New Member
Posts: 2
Joined: Sat May 30, 2009 11:47 am

Include a Template in anther Template

Post 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
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Include a Template in anther Template

Post 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.
piero.longhetto
New Member
New Member
Posts: 2
Joined: Sat May 30, 2009 11:47 am

Re: Include a Template in anther Template

Post 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.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Include a Template in anther Template

Post 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'}
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Include a Template in anther Template

Post 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...
Post Reply

Return to “CMSMS Core”