Jump to content


This topic is now archived and is closed to further replies.


Zend Pagination Problem

Recommended Posts



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?



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;



	$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
	// Make paginator available in your views
        $this->view->paginator = $paginator;



<div id="rightColumn">
			<h3>Latest News</h3>
			<?php if (count($this->paginator)): ?>
					<?php foreach ($this->paginator as $item): ?>
						foreach ($item as $k => $v)
							echo "<li>" . $v['title'] . "</li>";

					<?php endforeach; ?>
			<?php endif; ?>

<?= $this->paginationControl($this->paginator, 'Sliding', '/latestnews/partial_pagination_control.phtml'); ?> 



<?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; ?> 
<?php endif; ?> 



Any help would be great as I cannot work it out.

Thanks everyone


Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.