试图正确使用Smarty,我创建了一个配置文件。文件结构是这样的:Smarty:找不到配置文件
/Smarty/
/Smarty/cache
/Smarty/configs
/Smarty/configs/main.conf
/Smarty/plugins
/Smarty/sysplugins
/Smarty/templates_c
/templates/
/templates/main.tpl
index.php
在main.tpl我尝试加载从/Smarty/configs/main.conf的main.conf:http://www.smarty.net/docs/en/language.config.variables.tpl 这不起作用: {config_load "main.conf"}
这里解释(“致命错误:未捕获的异常‘SmartyException’有消息‘无法读取配置文件‘在... main.conf’’”),然而,这没有问题:
{config_load "/var/www/vhosts/*domain*/subdomains/cms/httpdocs/Smarty/configs/main.conf"}
为什么没有第一个例子工作?我之前设置了配置目录:
$smarty->setConfigDir(SMARTY_DIR.'configs/');
但找不到配置目录。有人可以帮我吗?提前致谢!
在调用'setConfigDir'来查看实际存在的路径后,打印'$ smarty-> getConfigDir()'。 – Eugene
@Eugene该路径似乎是正确的。它print_rs:“Array([0] =>/var/www/vhosts/* domain */subdomains/cms/httpdocs/Smarty/configs /)” –
你可以检查文件的权限吗?也许该文件没有读取权限。 –