Php Smarty中有两条不同的路径?
我在php项目中使用smartyPhp Smarty中有两条不同的路径?,php,smarty,Php,Smarty,我在php项目中使用smarty |->app |view |path_returned_by_handler.tpl |->lib |abstract |controller.php |view |path_to_be_used_by_controller.tpl 有一些处理程序将路径返回到某个子模板,但在display中,我想使用/lib/view/path\u,以便由\u controller.tpl使用
|->app
|view
|path_returned_by_handler.tpl
|->lib
|abstract
|controller.php
|view
|path_to_be_used_by_controller.tpl
有一些处理程序将路径返回到某个子模板,但在display中,我想使用/lib/view/path\u,以便由\u controller.tpl使用
在这个文件中,我将使用如下处理程序返回的路径
{include file=“$path\u由\u处理程序返回的\u”title=“sub\u temp”}
我该怎么做?
1) 一种解决方案是,我使用绝对路径,而不使用setTemplateDir,或者设置为顶级父目录,然后使用相对路径。
有更好的解决方案吗?如果要使用需要使用的相对路径,请在include开头使用 结构:
| index.tpl
|test
test.tpl
test3.tpl
|test2
test2.tpl
index.tpl
{include file="test/test.tpl"}
test.tpl
I'm test<br />
{include "./test3.tpl"}
{include "./test2/test2.tpl"}
因此,模板中的相对路径可以正常工作。它在最新的Smarty 3.1.18中进行了测试
I'm test 2<br />
I'm test 3<br />
I'm test
I'm test 3
I'm test 2