|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Loki Smarty Rookie
Joined: 13 Jan 2011 Posts: 30
|
Posted: Thu Jul 07, 2011 9:20 pm Post subject: Different bases for relative paths |
|
|
$template_dir = /some/path
template /some/path/sub/test.tpl
test.tpl
Code: | {include file="../main.tpl"}
{include file="main.tpl"}
|
In the case {include file="../main.tpl"} path starts from the current directory
/some/path/sub/../main.tpl
But in the case of {include file="main.tpl"} path starts from $template_dir
/some/path/main.tpl
Version 3.1
Is it normal?
Last edited by Loki on Fri Jul 08, 2011 4:17 pm; edited 1 time in total |
|
Back to top |
|
Loki Smarty Rookie
Joined: 13 Jan 2011 Posts: 30
|
Posted: Fri Jul 08, 2011 3:28 pm Post subject: |
|
|
/root/sub/bar.tpl
Code: | {include file="../foo.tpl"} {*try to load template in root*}
{include file="foo.tpl"} {*try to load template in sub*}
|
/root/foo.tpl
/root/sub/foo.tpl
Code: | $smarty = new Smarty;
$smarty->setTemplateDir('/root');
$smarty->display('sub/bar.tpl');
|
result is
Code: | foo in root
foo in root
|
It seems that this is a bug.
http://smarty-php.googlecode.com/svn/branches/Smarty_3_1_DEV
revision 4204 |
|
Back to top |
|
rodneyrehm Administrator
Joined: 30 Mar 2007 Posts: 674 Location: Germany, border to Switzerland
|
Posted: Fri Jul 08, 2011 5:42 pm Post subject: Re: Different bases for relative paths |
|
|
Loki wrote: | Is it normal? |
this is not only normal, but expected.
{include file="foo,tpl"}
translates to $smarty->fetch("foo.tpl") - thus regularly walking through the template_dir array
{include file="../foo,tpl"}
translates to $smarty->fetch(dirname($AbsolutePathOfCurrentTemplate) .'/../foo.tpl'); - thus only adressing one specific file relative to the current template.
This is (briefly) mentioned in the 3.1 notes: http://code.google.com/p/smarty-php/source/browse/branches/Smarty_3_1_DEV/distribution/SMARTY_3.1_NOTES.txt#191 |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|