Issues

ZF-4328: two paginators in same view (bug: second paginator has data from first paginator)

Description

I have a view in my administration which shows me my news articles, there two lists one which shows the last ten active news another one which shows the last 10 inactive articles.

If a publish two articles, the first paginator shows the two articles, but the second paginator also shows me that 2 articles were found but lists none, this is not true there are two active articles but no inactive article, i don't understand why the scond paginator shows me that two articles were found..?

can somebody help me? ;)

heres my source:

indexAction:

                           // active articles listing
                           $db = Zend_Registry::get('db');
                           $db->setFetchMode(Zend_Db::FETCH_ASSOC);

                           $articlesTable = new Articles();
                           $alist = $articlesTable->outputactive();

                           $paginator = Zend_Paginator::factory($alist);

                           $pageNumber = (int)$this->_request->getParam('page', 1);

                           $partial = '_partials/paginationControl.phtml';

                           Zend_View_Helper_PaginationControl::setDefaultViewPartial($partial);

                           $paginator      ->setItemCountPerPage(10)
                                           ->setPageRange(5)
                                           ->setCurrentPageNumber($pageNumber);

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

                           // INactive lists listing
                           $alist2 = $articlesTable->outputinactive();

                           $paginator2 = Zend_Paginator::factory($alist2);

                           Zend_View_Helper_PaginationControl::setDefaultViewPartial($partial);

                           $paginator2     ->setItemCountPerPage(10)
                                           ->setPageRange(5)
                                           ->setCurrentPageNumber($pageNumber);

                           $this->view->paginator2 = $paginator2;

articles model:

public function outputactive() {

   // list all active articles
           $articlesTable = new Articles();
           $query = "SELECT id, title FROM articles WHERE active=1 ORDER BY id";
           $db = $articlesTable->getAdapter();
           $result = $db->query($query);
           return $result->fetchAll();

}

public function outputinactive() {

   // list all inactive lists
   $articlesTable = new Articles();
           $query = "SELECT id, title FROM articles WHERE active=0 ORDER BY id";
           $db = $articlesTable->getAdapter();
           $result = $db->query($query);
           return $result->fetchAll();

}

articles index view:

if (count($this->paginator)) {

   foreach ($this->paginator as $list) {
         echo $list['title'].'<br />'
   }

   echo '<br /><br />';
   echo $this->paginationControl($this->paginator);

   echo '<br /><br />';

}

if (count($this->paginator2)) {

   foreach ($this->paginator2 as $list2) {
         echo $list2['title'].'<br />'
   }

   echo '<br /><br />';
   echo $this->paginationControl($this->paginator2);

   echo '<br /><br />';

}

pagination partial:

if ($this->pageCount) {

   echo 'Articles '.$this->firstItemNumber.' - '.$this->lastItemNumber.' de

'.$this->totalItemCount;

   echo '<br />';

   echo ' "'.$this- url(array('page' => $this->first)).'">First  | ';


   if (isset($this->previous)) {

           echo ' "'.$this- url(array('page' => $this->previous)).'">&lt; Previous

| ';

   } else {

           echo '&lt; Previous | ';

   }

   foreach ($this->pagesInRange as $page) {

           if ($page != $this->current) {

                   echo ' "'.$this- url(array('page' => $page)).'">'.$page.'  | ';

           } else {

           echo $page.' | ';

           }
   }

   if (isset($this->next)) {

           echo ' "'.$this- url(array('page' => $this->next)).'">Next &gt;  | ';

   } else {

           echo 'Next &gt; | ';

   }

   echo ' "'.$this- url(array('page' => $this->last)).'">Last ';

}

Comments

No comments to display