Smarty3.1X( 最新版本 3.1.19) 比起Smarty2.x修改了不少特性。我把这个模块使用Smarty3.1.18 ( 下载地址http://www.smarty.net/files/Smarty-3.1.18.zip )重新修改了一遍,是项目文件和目录看起来更干净更有调理。
把Smarty压缩包中的libs文件夹拷贝至模块根目录下,然后根目录创建init.inc.php:
require ROOT.\'libs/Smarty.class.php\';
$smarty = new Smarty();
//Smarty3设置默认路径
$smarty ->setTemplateDir(ROOT.\'templates/\')
->setCompileDir(ROOT.\'templates_c/\')
->setPluginsDir(ROOT.\'plugins/\')
->setCacheDir(ROOT.\'cache/\')
->setConfigDir(ROOT.\'configs\');
$smarty->caching = false;
$smarty->cache_lifetime = 60*60*24; //模版缓存有效时间为1天
$smarty->left_delimiter = \'<{\';
$smarty->right_delimiter = \'}>\';
/***********************************************************/
//根目录url方式
$PHP_SELF=$_SERVER[\'PHP_SELF\'];
$ROOT_URL=\'http://\'.$_SERVER[\'HTTP_HOST\'].substr($PHP_SELF,0,strrpos($PHP_SELF,\'/\')+1);
define(ROOT_URL,$ROOT_URL);
//模版目录url方式
define(\"Template_Dir\",$ROOT_URL.\'templates\');
本文地址:https://www.stayed.cn/item/20830
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我