2011-03-08 91 views
2

警告:部分提供無景觀和 沒有默認的 /Applications/MAMP/htdocs/getv/library/Zend/Paginator.php 設置上線465分頁程序Zend框架警告

這是加載分頁程序時得到的警告消息;有人可以給我一個解決方案或提示,我的問題可能是什麼?

public function getPaginator() { 
    if ($this->view === null) { 
     $this->view = $this->getActionController()->view; 
    } 

    $db = Zend_Db_Table::getDefaultAdapter(); 

    /* @var $searcher ZendX_Searcher_Abstract */ 
    foreach ($this->searchers as $searcher) { 
     $searcher->setRequest($this->getRequest()) 
       ->setView($this->view) 
       ->setSelect($this->select) 
       ->perform(); 
    } 

    $paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($this->select)); 
    $paginator->setCurrentPageNumber($this->getRequest()->getParam('page', 1)); 
    $paginator->setPageRange(7); 

    if ($this->perPage > 0) { 
     $paginator->setItemCountPerPage($this->perPage); 
    } else { 
     $paginator->setItemCountPerPage(PHP_INT_MAX); 
    } 

    return $paginator; 
} 
+2

我想你需要:'Zend_View_Helper_PaginationControl :: setDefaultViewPartial('paginator.phtml'); ' – RobertPitt 2011-03-08 11:03:09

回答

0

此錯誤不是由您的控制器觸發的,而是從您的視圖中觸發的。

顯示在您調用<?php echo $this->paginationControl(...) ?>

僅供參考腳本,你需要至少兩件提供給PaginationControl視圖助手:

  1. 一個Zend_Paginator對象。作爲助手的第一個參數提供,或者將其設置爲視圖的paginator屬性。
  2. 部分視圖路徑。作爲視圖助手的第三個參數提供(在scrollingStyle之後)或通過RobertPitt在他的評論中提到的靜態方法提供。
1

嘿,我遇到了同樣的問題。我正在使用zend分頁視圖助手。我得到的解決方案有點奇怪。在視圖(一個.phtml)文件我檢查喜歡

if(isset($this->records) && $this->records!='') 

但後來比我將其更改爲

if(isset($this->records) && sizeof($this->records) > 0) 

,我的問題解決了。希望,這可能對你和其他人有所幫助。

1

正確的解決辦法是什麼IMO提出RobertPitt:

Zend_View_Helper_PaginationControl::setDefaultViewPartial ('paginator.phtml'); 
0

在我來說,我不給來查看空的分頁程序對象,但一個空字符串,是爲了避免在初始未過濾的搜索。 我以這種方式解決了我的view.phtml:

if (is_a($this->paginator,'Zend\Paginator\Paginator')) { 
    // paginator print 
} 

我希望這幫助。