Robert Munteanu
Robert Munteanu

Reputation: 68278

Smarty: including a template file from the same directory

I have a Smarty template located in a directory under templates_dir: templates/some/dir/template.tpl . In the same directory, I have a sub-template: templates/some/dir/_component.tpl .

I can't include the sub-component using an unqualified include, since apparently it looks it up under the templates_dir:

{include file='_component.tpl'}

How can I tell Smarty to read the file from the same directory, as opposed to the templates root ? I do not want to specify absolute paths, since it will cause problems when changing directory structures.

Upvotes: 0

Views: 1226

Answers (1)

webbiedave
webbiedave

Reputation: 48897

Could your app pass the template dir to the template so it can use it to create an absolute path?

$smarty->assign('template_d­ir', $smarty->template_d­ir);

Upvotes: 2

Related Questions