Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Smarty模板目录-映射包含在不同文件夹中调用模板的路径_Php_Smarty - Fatal编程技术网

Php Smarty模板目录-映射包含在不同文件夹中调用模板的路径

Php Smarty模板目录-映射包含在不同文件夹中调用模板的路径,php,smarty,Php,Smarty,是否有可能覆盖 {include file='fake/path/to/template.tpl'} 要在其他文件夹中实际包含模板,请执行以下操作: real/path/to/template.tpl 我这样问是因为我们最近将代码插件的一些部分移到了供应商文件夹中,我们正试图找到一个简单的解决方案,而不必更改每个smarty文件。有几百个 如果我们可以避免使用符号链接,那就太好了 您可以编写一个函数,该函数接受字符串假url并输出字符串真url function getRealURL($tp

是否有可能覆盖

{include file='fake/path/to/template.tpl'}
要在其他文件夹中实际包含模板,请执行以下操作:

real/path/to/template.tpl
我这样问是因为我们最近将代码插件的一些部分移到了供应商文件夹中,我们正试图找到一个简单的解决方案,而不必更改每个smarty文件。有几百个


如果我们可以避免使用符号链接,那就太好了

您可以编写一个函数,该函数接受字符串假url并输出字符串真url

function getRealURL($tpl_filename) {
    $path = '../real/path/to/';
    if(file_exists($path.$ui_view)) {
        return $ui_view;
    }
    return $tpl_filename;
}
我正在使用一个与其他因素类似的函数,但这是它的基础,并验证了新文件是否以给定路径存在。它还可以轻松地用于特定目录中的文件白名单

我相信你可以这样称呼它。 {include file='fake/path/to/template.tpl'| getRealURL}