繁体   English   中英

Smarty:包含来自同一目录的模板文件

[英]Smarty: including a template file from the same directory

我有位于目录下的Smarty的模板templates_dir :模板/一些/ DIR / template.tpl。 在同一目录中,我有一个子模板:templates / some / dir / _component.tpl。

我不能使用不合格的包含来包含子组件,因为显然它是在templates_dir下查找它的:

{include file='_component.tpl'}

如何告诉Smarty从同一目录(而不是模板根目录)读取文件? 我不想指定绝对路径,因为在更改目录结构时会引起问题。

您的应用程序能否将模板目录传递给模板,以便它可以使用它创建绝对路径?

$smarty->assign('template_dir', $smarty->template_dir);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM