"Görüşlerini" nasıl taşınır

2 Cevap php

Normal olarak bu tür bir yapıda olacaktır:

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

: Ben bunu nasıl hareket

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

?

2 Cevap

Sen oynamak gerekir: $viewRenderer::setViewBasePathSpec();

frontController eklentisi, örneğin (ya da daha kolay, ama çok esnek değil, içinde 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, view, layout ve viewRenderer sınıflarında alıcılar ve ayarlayıcıları bir göz atın. Varsayılan dizin yapısını özelleştirmek için izin yöntemler bol vardır.

Ben bir eklenti ile yaptım, ve tema adını belirtmek benim config bir değişken.

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