2010-03-15 2 views
2

의 "뷰"로 이동합니다 :어떻게 일반적으로는 이러한 구조에있을 것입니다 Zend_Layout

../application/modules/somemodule/views/scripts/index/index.phtml 

나는 그것을 이동 방법 :

../application/templates/somemodule/template1/views/...... 
../application/templates/somemodule/templateTWOOMG/....... 

? (Bootstrap.php에서, 또는 쉽게,하지만 너무 유연하지) frontController 플러그인, 예를 들어 $viewRenderer::setViewBasePathSpec();

:

답변

3

당신은 함께 플레이 할 필요가

$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, layoutviewRenderer 클래스이다. 기본 디렉토리 구조를 사용자 정의 할 수있는 많은 메소드가 있습니다.

0

나는 그것을 플러그인으로 만들었고 내 구성에 테마의 이름을 지정하는 변수를 설정했다.

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; 
    } 
}