smarty获取多个模板文件夹

时间:2017-05-01 09:19:55

标签: php smarty

我尝试在smarty中制作两个不同的模板,但有些不对劲。

我的课程: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): 

想要为我的网站和adminpanel加载两个不同的文件夹。两个文件夹都位于相同的主文件夹中,称为样式。

1 个答案:

答案 0 :(得分:1)

尝试使用:

if (request.getRequestURI().endsWith(".html")) {
  request.getServletContext()
    .getNamedDispatcher("application-html")
    .forward(request, response)
}