Zend pagination
Zend pagination is a default option available in zend framework. Only needs to use it .The codes are apply in controller and view
class Admin_PollsocietiesController extends Core_Controller_Action
{
public function listsocreqAction()
{
$oSocReqs = new Model_Societysignup();
$aSocReqs = $oSocReqs->getPendingRequests();
unset($oSocReqs);
//for pagination
$climit = 20;
$page1 = $this->_getParam(‘page’,1);
$paginator = Zend_Paginator::factory($aSocReqs);
$paginator->setItemCountPerPage($climit);
$paginator->setCurrentPageNumber($page1);
$this->view->paginator=$paginator;
$this->view->assign(‘aSocs’, $paginator);
}
}
view
<?php echo $this->paginationControl($this->paginator, ‘Sliding’, ‘pollsocieties/pagination.phtml’); ?>
pagination.phtml
<div style=”width:100%”>
<div style=”float:left;width:28%”>
</div>
<div style=”float:right;width:70%;”>
<!– First page link –>
<?php if (isset($this->previous)): ?>
<a href=”<?= $this->url(array(‘page1’ => $this->first)); ?>”>Start</a> |
<?php else: ?>
<span>Start</span> |
<?php endif; ?>
<!– Previous page link –>
<?php if (isset($this->previous)): ?>
<a href=”<?= $this->url(array(‘page1’ => $this->previous)); ?>”>< Previous</a> |
<?php else: ?>
<span>< Previous</span> |
<?php endif; ?>
<!– Numbered page links –>
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page1 ! = $this->current): ?>
<a href=”<?= $this->url(array(‘page1’ => $page1)); ?>”><?= $page1; ?></a>
<?php else: ?>
<?= $page1; ?>
<?php endif; ?>
<?php endforeach; ?>
<!– Next page link –>
<?php if (isset($this->next)): ?>
| <a href=”<?= $this->url(array(‘page1’ => $this->next)); ?>”>Next ></a> |
<?php else: ?>
| <span>Next ></span> |
<?php endif; ?>
<!– Last page link –>
<?php if (isset($this->next)): ?>
<a href=”<?= $this->url(array(‘page1’ => $this->last)); ?>”>End</a>
<?php else: ?>
<span>End</span>
<?php endif; ?>
Page1 <?= $this->current; ?> of <?= $this->last; ?>
</div>
</div>