Normally it would be in such a structure:
../application/modules/somemodule/views/scripts/index/index.phtml
How I move it to:
../application/templates/somemodule/template1/views/......
../application/templates/somemodule/templateTWOOMG/.......
??
You need to play with: $viewRenderer::setViewBasePathSpec();
For example in frontController
plugin, (or easier, but not so flexible, in 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/");
Take a look on getters and setters in frontController
, view
, layout
and viewRenderer
classes. There are plenty of methods which allow to customize default directory structure.
I did it with a plugin, and set a variable in my config to specify the name of the theme.
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;
}
}