包括从根开始的路径

Include path from root

我的结构有点像这样:

src
---stuff1
------stuff2
---------stuff3
------------tpl1.tpl
---dir1
------dir2
---------dir3
------------tpl2.tpl

我想在tpl1.tpl中包含tpl2.tpl,如何避免这样的怪物:{include file="../../../../../dir1/dir2/dir3/tpl.tpl"}

php 文件:

<?php
$root = "/path/to/the/root/of/my/site/or/templates"
$smarty->assign('root',$root);

模板文件:

{include file="`$root`/dir1/dir2/myfile.tpl"}

{include file="$root/dir1/dir2/myfile.tpl"}

{include file="$root|cat:"/dir1/dir2/myfile.tpl"}

http://www.smarty.net/docs/en/language.syntax.quotes.tpl