Pagination of zend Reviewed by Momizat on . Zend pagination feature is the best.It is provide many types of styles like:- Styles of pagination All: It is show all pages in pagination. Elastic: It is show Zend pagination feature is the best.It is provide many types of styles like:- Styles of pagination All: It is show all pages in pagination. Elastic: It is show Rating: 0

Pagination of zend

Zend pagination feature is the best.It is provide many types of styles like:-

Styles of pagination

  • All: It is show all pages in pagination.
  • Elastic: It is show as a google pagination style.
  • Sliding: It is show as a yahoo pagination style.
  • Jumping: It is show as a jump according to range limit.

Use in controller

<?php
 public function adminUsersAction()
 {
		$this->view->h1="All Admin Users";		
		$result =$this->objback->getalluser();
		$page=$this->_getParam('page',1);
		$paginator = Zend_Paginator::factory($result);
		$paginator->setItemCountPerPage(10);
		$paginator->setCurrentPageNumber($page);
		$paginator->setPageRange(5);
		$this->view->paginator=$paginator;

}
?>

Use in view

<?php
<div class="table-responsive">	
	<table class="table">
		<thead>
			<tr>											
				<th>S.N</th>
				<th>Name</th>
				<th>Primary Email</th>
				<th>Status</th>
				<th>Action</th>
			</tr>
		</thead>
		<tbody>
		<?php 
		
		$k=1;
		foreach($this->paginator as $adminusersvl){?>
			<tr class="odd gradeX">
				<td class="center"><?php echo $k++;?></td>										
				<td class="center"><?php echo ucwords($adminusersvl['name']);?></td>
				<td class="center"><a href="mailto:<?php echo $adminusersvl['email'];?>"><?php echo $adminusersvl['email'];?></a></td>
				<td class="center"><?php echo ($adminusersvl['status']==0?'<span style="color:red;font-weight:bold;">OFFLINE</span>':'<span style="font-weight:bold;color:green;">ONLINE</span>');?></td>
				<td class="center"><a href="<?php  echo $this->url(array('controller' => 'user', 'action' => 'edit-adminuser','id'=>$adminusersvl['id']));?>"><i class="fa fa-pencil"></i>Edit</a></td>
			</tr>
		<?php }?>
			
		</tbody>
	</table>							
</div>
 <?php echo  $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>
?>

view/script/pagination.phtml

<?php
<ul class="pagination">
        <!-- First page link -->
        <?php if (isset($this->previous)): ?>
              <li><a href="<?php echo $this->url(array('page' => $this->first)); ?>">&lt;&lt;</a></li>
        <?php else: ?>
                <li class="disabled"><a href="#">&lt;&lt;</a></li>
        <?php endif; ?>
    
        <!-- Previous page link -->
    
        <?php if (isset($this->previous)): ?>
              <li><a href="<?php echo $this->url(array('page' => $this->previous)); ?>">&lt; </a></li>
        <?php else: ?>
            <li class="disabled"><a href="#">&lt; </a></li>
        <?php endif; ?>
        <!-- Numbered page links -->
        <?php foreach ($this->pagesInRange as $page): ?>
            <?php if ($page != $this->current): ?>
			
                <li ><a href="<?php echo $this->url(array('page' => $page)); ?>"><?php echo $page; ?></a></li>
			
            <?php else: ?>
                <li class="active"><a href="#"><?php echo $page; ?></a></li>
            <?php endif; ?>
        <?php endforeach; ?>
        <!-- Next page link -->
        <?php if (isset($this->next)): ?>
              <li><a href="<?php echo $this->url(array('page' => $this->next)); ?>">&gt;</a></li>
        <?php else: ?>
            <li class="disabled"><a href="#">&gt;</a></li>
        <?php endif; ?>
        <!-- Last page link -->
        <?php if (isset($this->next)): ?>
              <li><a href="<?php echo $this->url(array('page' => $this->last)); ?>">&gt;&gt;</a></li>
        <?php else: ?>
           <li class="disabled"><a href="#">&gt;&gt;</a></li>
        <?php endif; ?>
         <li><a href="#">&nbsp; Page <?php echo $this->current; ?> of <?php echo $this->last; ?></a> </li>
    </ul>
?>

Leave a Comment

© 2014 Powered By