zend predispatch layoutloader

时间:2012-07-24 12:15:20

标签: php zend-framework

嗨我需要一个zend布局加载器的帮助以下是我的代码不能正常工作!!

public function preDispatch(){

    $bootstrap = $this->getActionController()->getInvokeArg('bootstrap');
    $config = $bootstrap->getOptions();
    Zend_Registry::set('config', $config);
    $module = $this->getRequest()->getModuleName();
    $controller = $this->getRequest()->getControllerName();
    $action = $this->getRequest()->getActionName();
}

感谢

1 个答案:

答案 0 :(得分:0)

    public function preDispatch(){

    $bootstrap = $this->getActionController()->getInvokeArg('bootstrap');
    $config = $bootstrap->getOptions();
    Zend_Registry::set('config', $config);
    $module = $this->getRequest()->getModuleName();
    $controller = $this->getRequest()->getControllerName();
    $action = $this->getRequest()->getActionName();

    $layoutScript = "layout";
    if (isset($config[$module]['resources']['layout']['layout'])) {
        $layoutScript = $config[$module]['resources']['layout']['layout'];
    }
    $this->getActionController()->getHelper('layout')->setLayout($layoutScript);
}

感谢