Skip to content

Instantly share code, notes, and snippets.

@iamtchelo
Last active August 29, 2015 14:06
Show Gist options
  • Save iamtchelo/9abbbbbd73d7090a9316 to your computer and use it in GitHub Desktop.
Save iamtchelo/9abbbbbd73d7090a9316 to your computer and use it in GitHub Desktop.
A simple paginator with ZF2 and Bootstrap
<?php if ($this->pageCount): ?>
<ul class="pagination">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li><a href="<?php echo $this->url($this->route, array('controller' => $this->controller, 'page' => $this->previous)); ?>">&laquo;</a></li>
<?php else: ?>
<li class="disabled"><a>&laquo;</a></li>
<?php endif; ?>
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<li><a href="<?php echo $this->url($this->route, array('controller' => $this->controller, 'page' => $page)); ?>"><?php echo $page ?></a></li>
<?php else: ?>
<li class="active"><a href="<?php echo $this->url($this->route, array('controller' => $this->controller, 'page' => $page)); ?>"><?php echo $page ?></a></li>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<li><a href="<?php echo $this->url($this->route, array('controller' => $this->controller, 'page' => $this->next)); ?>">&raquo;</a></li>
<?php else: ?>
<li class="disabled"><a>&raquo;</a></li>
<?php endif; ?>
</ul>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment