通常它会是这样的结构:
../application/modules/somemodule/views/scripts/index/index.phtml
我如何将其移至:
../application/templates/somemodule/template1/views/......
../application/templates/somemodule/templateTWOOMG/.......
??
通常它会是这样的结构:
../application/modules/somemodule/views/scripts/index/index.phtml
我如何将其移至:
../application/templates/somemodule/template1/views/......
../application/templates/somemodule/templateTWOOMG/.......
??
你需要玩:$viewRenderer::setViewBasePathSpec();
例如在frontController
插件中,(或更简单,但不那么灵活,在Bootstrap.php
):
$templateName = 'myTemplate';
$bootstrap = $this->getBootstrap();
$bootstrap->bootstrap('layout');
if ($bootstrap->hasResource('layout')) {
$layout = $bootstrap->getResource('layout');
$layout->setLayoutPath($basePath . '/layouts/scripts/');
}
$bootstrap->bootstrap('view');
if ($bootstrap->hasResource('view')) {
$view = $bootstrap->getResource('view');
} else {
$view = new Zend_View;
}
$vr = Zend_Controller_Action_HelperBroker::getExistingHelper("viewRenderer");
$vr->setViewBasePathSpec($basePath."/modules/:module/$templateName/views/");
看一下 、 和 类中的frontController
getter和setter view
。有很多方法可以自定义默认目录结构。layout
viewRenderer
我使用插件完成了它,并在我的配置中设置了一个变量来指定主题的名称。
class Application_Plugin_ThemeSetup extends Zend_Controller_Plugin_Abstract
{
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
// load up the config and the view object
$objConfig = Zend_Registry::get('config');
$objView = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
// set path for views based on theme designation in config
$theme = ! empty($objConfig->theme->name) ? $objConfig->theme->name : 'default';
$Renderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$Renderer->setViewBasePathSpec(APPLICATION_PATH."/views/$theme");
// add some variable to the view at high level
$objView->themeName = $objConfig->theme->name;
$objView->themeDescription = $objConfig->theme->description;
}
}