0

我正在尝试使用 zend 在 jquery 移动框架中实现分页。我有以下从控制器中获取的代码,

...
        $message_list = $this->help->browse($browseArray); 
        $this->view->vCount = count($message_list); 
        $paginator = Zend_Paginator::factory($message_list);
        $page = ($postData['page'] > 0) ? $postData['page'] : 1;
        $paginator->setCurrentPageNumber($page);
        $paginator->setItemCountPerPage(10);
        $paginator->setPageRange(5);

        $this->view->message_list = $paginator;   
....

我还从模板页面中获取了以下代码,

....
    <ul data-role="listview"  data-theme="e">
        <?php foreach ($this->message_list as $key => $value) { ?>
            <li>
                <img src="<?php echo BASE_URL; ?>public/common/images/mobile/jqueryMobile200Thumb.jpg" alt="" />
                <h3><a href="<?php echo $this->url(array("controller" => "help", "action" => "dohelp", "id" => $value['helpid'])); ?>"><?php echo $value['title']; ?></a></h3>
                <p><?php echo $value['content']; ?></p>
            </li>
        <?php } ?>    
            <li>
                <?php echo $this->paginationControl($this->message_list, 'Sliding', 'pagination.phtml'); ?>
            </li>           
    </ul>
....

当我运行该站点时,出现以下异常

        Exception information:

        Message: No paginator instance provided or incorrect type
        Stack trace:

        #0 [internal function]: Zend_View_Helper_PaginationControl->paginationControl(NULL, 'Sliding', 'pagination.phtm...')
#1 C:\xampp\htdocs\test\library\Zend\View\Abstract.php(350): call_user_func_array(Array, Array)
#2 C:\xampp\htdocs\test\application\mobile\views\scripts\help\messagelist.phtml(32): Zend_View_Abstract->__call('paginationContr...', Array)
#3 C:\xampp\htdocs\test\application\mobile\views\scripts\help\messagelist.phtml(32): Zend_View->paginationControl(NULL, 'Sliding', 'pagination.phtm...')
#4 C:\xampp\htdocs\test\library\Zend\View.php(108): include('C:\xampp\htdocs...')
#5 C:\xampp\htdocs\test\library\Zend\View\Abstract.php(888): Zend_View->_run('C:\xampp\htdocs...')
#6 C:\xampp\htdocs\test\library\ZC\Controller\Plugin\Mobile.php(54): Zend_View_Abstract->render('help/messagelis...')
#7 C:\xampp\htdocs\test\library\Zend\Controller\Plugin\Broker.php(287): ZC_Controller_Plugin_Mobile->dispatchLoopStartup(Object(Zend_Controller_Request_Http))
#8 C:\xampp\htdocs\test\library\Zend\Controller\Front.php(928): Zend_Controller_Plugin_Broker->dispatchLoopStartup(Object(Zend_Controller_Request_Http))
#9 C:\xampp\htdocs\test\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 C:\xampp\htdocs\test\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 C:\xampp\htdocs\test\index.php(34): Zend_Application->run()
#12 {main}  
    ....

我在这方面做错了什么。请帮助我。

4

2 回答 2

1

试试这个方法:

$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_Array($message_list));

要回答您的问题,出现错误$this->message_list是因为null尝试调试它的原因null

于 2012-04-12T07:29:23.237 回答
0

检查您是否$paginator在视图对象中正确设置了变量。我遇到了这种情况,发现我没有正确地这样做。

于 2014-03-06T08:37:05.563 回答