smarty 获取多个模板文件夹

smarty get multi template folders

我尝试在 smarty 中制作两个不同的模板,但出了点问题。

我的class:SmartyTpl.php

require_once(HOME . '/lib/smarty/Autoloader.php');

class SmartyTpl {

static private $instance;

public static function instance() {
    if (!isset(self::$instance)) {
        Smarty_Autoloader::register();
        $smarty = new Smarty;
        //$smarty->caching = Smarty::CACHING_LIFETIME_CURRENT;
        $smarty->debugging = 1;
        self::$instance = $smarty;
    }
    return self::$instance;
}

}

和Core.php

SmartyTpl::instance()->setTemplateDir(array('web' => HOME . '/style/web/'. $front . '/templates/', 
                                              'admin' => HOME . '/style/admin/'. $back . '/templates/'));
 SmartyTpl::instance()->setCompileDir(array('web' => HOME . '/style/web/'. $front . '/templates_c/', 
                                             'admin' => HOME . '/style/admin/'. $back . '/templates_c/'));
SmartyTpl::instance()->setConfigDir(array('web' => HOME . '/style/web/'. $front . '/configs/', 
                                            'admin' => HOME . '/style/admin/'. $back . '/configs/'));

 SmartyTpl::instance()->getTemplateDir = 'web';
 SmartyTpl::instance()->getTemplateDir = 'admin';

 SmartyTpl::instance()->getCompileDir = 'web';
 SmartyTpl::instance()->getCompileDir = 'admin';

 SmartyTpl::instance()->getConfigDir = 'web';
 SmartyTpl::instance()->getConfigDir = 'admin' ;

 SmartyTpl::instance()->cache_dir = HOME . '/files/cache/';

$back 和 $front 为默认值 default

错误是:

   unable to write file //wrt5906fb649f4d77_79203986#0 /home/a/testdemo/testdemo/public_html/lib/smarty/sysplugins/smarty_template_compiled.php(215): 

我想为我的站点和管理面板加载两个不同的文件夹。这两个文件夹都在同一个名为 style 的主文件夹中。

尝试使用:

SmartyTpl::instance()->template_dir = array(HOME . '/style/web/' .$front. '/templates/', .HOME . '/style/admin/'. $back. '/templates/');
SmartyTpl::instance()->compile_dir = array(HOME . '/style/web/'.$front. '/templates_c/', .HOME . '/style/admin/'.$back. '/templates_c/');
SmartyTpl::instance()->config_dir = array(HOME . '/style/web/'.$front. '/configs/', HOME . '/style/admin/'.$back. '/configs/');
SmartyTpl::instance()->cache_dir = HOME . '/files/cache/';