Zend Framework视图脚本不包含父类的变量

时间:2012-01-08 18:04:26

标签: zend-framework view

我为几个控制器创建了一个父CRUD类,当我渲染脚本时,它没有识别我在listAction()中设置的paginator变量。代码来自我的父类。例如,我将Admin_UserController扩展为创建Webapp_Controller_Crud

class Webapp_Controller_Crud extends Zend_Controller_Action
{
    public function init()
    {
        $actionController = get_class($this);
        $actionController = str_replace('Admin_',null,$actionController);
        $actionController = str_replace('Controller',null,$actionController);
        $this->_actionClassName = $actionController;
        $actionController = 'Model_' . $this->_actionClassName;     
        $this->_actionModel = new $actionController();              
    }

    /**
 * @return Zend_Paginator
 */
    public function getPaginator()
    {
        $model = $this->getActionModel();
        $adapter = new Zend_Paginator_Adapter_DbSelect($model->select());
        $paginator  = new Zend_Paginator($adapter);
        $paginator->setItemCountPerPage(10);
        $page = $this->_request->getParam('page', 1);
        $paginator->setCurrentPageNumber($page);
        return $paginator;
    }
    public function listAction()
    {       
        $this->view->paginator = $this->getPaginator();             
    }

}

1 个答案:

答案 0 :(得分:0)

您使用

$this->getView()->paginator = $this->getPaginator();

哪个应该是

$this->view->paginator = $this->getPaginator();
相关问题