s_ainley87 Posted January 7, 2009 Share Posted January 7, 2009 Hello, I am having a problem with my zend pagination, in that it is not pagination at, I try and set a limit of 4 record per page but it ignores, I can for the life in me see the problem I was hoping someone with sharp eyes could? model public function getAllNews() { $db = Zend_Registry::get('db'); $sql = "SELECT * FROM $this->_name WHERE flag = 1 ORDER BY created_at"; $query = $db->query($sql); while ($row = $query->fetchAll()) { $result[] = $row; } return $result; } controller $this->_helper->layout->setLayout('latestnews'); Zend_Loader::loadClass('newsArticles'); $allNews = new newsArticles(); $this->view->allNews = $allNews->getAllnews(); //die (var_dump($this->view->allNews)); $data = $this->view->allNews; // Instantiate the Zend Paginator and give it the Zend_Db_Select instance Argument ($selection) $paginator = Zend_Paginator::factory($data); // Set parameters for paginator $paginator->setCurrentPageNumber($this->_getParam("page")); $paginator->setItemCountPerPage(4); $paginator->setPageRange(4); // Make paginator available in your views $this->view->paginator = $paginator; //die(var_dump($data)); view <div id="rightColumn"> <h3>Latest News</h3> <?php if (count($this->paginator)): ?> <ul> <?php foreach ($this->paginator as $item): ?> <?php foreach ($item as $k => $v) { echo "<li>" . $v['title'] . "</li>"; } ?> <?php endforeach; ?> </ul> <?php endif; ?> <?= $this->paginationControl($this->paginator, 'Sliding', '/latestnews/partial_pagination_control.phtml'); ?> </div> pagination_template <?php if ($this->pageCount): ?> <div class="paginationControl"> <!-- Previous page link --> <?php if (isset($this->previous)): ?> <a href="<?= $this->url(array('page' => $this->previous)); ?>">< Previous</a> | <?php else: ?> <span class="disabled">< Previous</span> | <?php endif; ?> <!-- Numbered page links --> <?php foreach ($this->pagesInRange as $page): ?> <?php if ($page != $this->current): ?> <a href="<?= $this->url(array('page' => $page)); ?>"><?= $page; ?></a> | <?php else: ?> <?= $page; ?> | <?php endif; ?> <?php endforeach; ?> <!-- Next page link --> <?php if (isset($this->next)): ?> <a href="<?= $this->url(array('page' => $this->next)); ?>">Next ></a> <?php else: ?> <span class="disabled">Next ></span> <?php endif; ?> </div> <?php endif; ?> Any help would be great as I cannot work it out. Thanks everyone Link to comment https://forums.phpfreaks.com/topic/139868-zend-pagination-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.