Page 1 of 1
How to include a *.tpl file in my template???
Posted: Thu Mar 20, 2008 12:31 pm
by jmansa
Is it possible to include a *.tpl file inside my template.html, and if yes... How?
I have tryid this:
{include file="/templates/sommerbar.tpl"}
But get this error:
string(65) "Smarty error: unable to read resource: "/templates/sommerbar.tpl""
Hope somebody can help!!!
Re: How to include a *.tpl file in my template???
Posted: Thu Mar 20, 2008 6:44 pm
by RonnyK
Did you try without the leading "/" as that starts at the root, instead of the CMSMS-root, so you might try with a relative path....
Ronny
Re: How to include a *.tpl file in my template???
Posted: Thu Mar 20, 2008 10:37 pm
by calguy1000
Well, 1: CMS doesn't have a templates directory, so you'd have to create one
then 2: have you tried (after creating the directory above) calling {include file="something.tpl"}
Re: How to include a *.tpl file in my template???
Posted: Wed Jun 04, 2008 4:11 am
by JeremyBASS
Was there any fix to this? I tryed it too and only got string(54) "Smarty error: unable to read resource: "Test_Page.tpl"" useing {include file='Test_Page.tpl'} in the templates. The folld which is located in the root named templates. Would love to see this work.
jeremyBass
Re: How to include a *.tpl file in my template???
Posted: Wed Jun 04, 2008 7:39 am
by cyberman
Hi Jeremy,
JeremyBASS wrote:
The folld which is located in the root named templates.
Like calguy said
calguy1000 wrote:
Well, 1: CMS doesn't have a templates directory, so you'd have to create one
/tmp/templates is not the template folder, which Smarty means
http://www.smarty.net/manual/en/api.var ... mplate.dir
You can try it to assign via user defined tag (before your include call)
Code: Select all
global $gCms;
$smarty->template_dir = $config['root_path'].'/tmp/templates';
Re: How to include a *.tpl file in my template???
Posted: Wed Jun 04, 2008 3:09 pm
by JeremyBASS
Just FYI No, {include file='Test_Page.tpl'} does works, I had to move the templates folder to /tmp/templates on the root... so yes /tmp/templates
isnot the template folder, which Smarty means.
Thanks for the help...

have a great one...
Re: How to include a *.tpl file in my template???
Posted: Sat Jun 15, 2024 7:08 pm
by Deykun
A response from the far future. Add
plugins/function.get_tpl.php:
Code: Select all
<?php
//opcache_reset();
function smarty_function_get_tpl($params, $smarty)
{
// empty($params['name']
$config = cmsms()->GetConfig();
$smarty->display($config['root_path'] . '\your_path\\' . $params['path']);
}
?>
Use:
Code: Select all
{get_tpl path=”sections\\SectionFormProduct.tpl”}
Re: How to include a *.tpl file in my template???
Posted: Mon Jun 17, 2024 10:26 am
by Jo Morg
For the sake of clarity:
- when this thread started CMSMS had a different and more limited mechanism to handle with templates in files; This is no longer the case;
- using an UDT as suggested by Deykun is a valid possibility, but not needed nor recommended;
- the correct way to use tpl files is as follows:
- use assets\templates as the root for your templates organization;
- use any hierarchy of folders you wish, say add a common folder for example;
- if you added a top_logic.tpl template file inside the common folder, then you can call from any of your other templates:
As simple as that! HTH!