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行爲一樣工作?