0
我正在使用ZF制作客户门户应用程序。门户网站需要为不同的公司品牌工作。所以我需要使用所有相同的后端代码/控制器/ etc,但是根据主机名动态更改视图目录。动态设置查看目录
现在我的观点的目录结构看起来是这样的:
/application/views/scripts/brand1/
/application/views/scripts/brand1/index/index.phtml
/application/views/scripts/brand1/error/error.phtml
/application/views/scripts/brand2/
/application/views/scripts/brand2/index/index.phtml
/application/views/scripts/brand2/error/error.phtml
/application/views/scripts/brand3/
/application/views/scripts/brand3/index/index.phtml
/application/views/scripts/brand3/error/error.phtml
and so on.
我使用addScriptPath()函数在bootstrap.php中,像这样
protected function _initView()
{
$view = new Zend_View();
$view->doctype('XHTML1_STRICT');
$view->env = APPLICATION_ENV;
$view->addScriptPath(APPLICATION_PATH . '/views/scripts/brand1');
$view->addHelperPath(APPLICATION_PATH . '/views/helpers');
...
}
然而,当这个运行时,它使用/views/scripts/brand1/(action).phtml查找所有视图,而不是使用正确的方案查找视图/view/scripts/brand1/(controller)/(action).phtml
tl; dr是否可以动态选择视图目录,并使它像默认的/views/scripts/(controller)/(action).phtml行为一样工作?