Skip to content

Instantly share code, notes, and snippets.

@snetty
Created November 8, 2013 09:57
Show Gist options
  • Save snetty/7368825 to your computer and use it in GitHub Desktop.
Save snetty/7368825 to your computer and use it in GitHub Desktop.
Lemonstand Pagination for Bootstrap
<?
$curPageIndex = $pagination->getCurrentPageIndex();
$pageNumber = $pagination->getPageCount();
$suffix = isset($suffix) ? $suffix : null;
?>
<? if($pageNumber != 1) : ?>
<div class="text-center">
<ul class="pagination">
<li>
<a href="#" class="disabled">
Page <strong><?= !$curPageIndex ? 1 : $curPageIndex+1 ?> </strong>
of <strong><?= $pageNumber ?></strong>
</a>
</li>
<li><a class="<? if(!$curPageIndex) : ?>disabled<? endif; ?>" href="<?= $base_url.$suffix ?>" title="First Page">&laquo;</a></li>
<li><a class="<? if(!$curPageIndex): ?>disabled<? endif; ?> href="<?= $base_url.'/'.$curPageIndex.$suffix ?>" title="Previous Page">&lsaquo;</a></li>
<? if($pagination->getPageCount() > 1) : ?>
<? for ($i=1; $i<=$pageNumber; $i++): ?>
<? if((($curPageIndex+1) >= ($i-3)) && (($curPageIndex+1) <= ($i+3))) : ?>
<li><a class="<? if ($i == $curPageIndex+1): ?>active<? endif; ?>" href="<?= $base_url.'/'.$i.$suffix ?>"><?= $i ?></a></li>
<? endif; ?>
<? endfor ?>
<? endif; ?>
<li><a class="<? if($curPageIndex >= $pageNumber-1) : ?>disabled<? endif; ?>" href="<?= $base_url.'/'.($curPageIndex+2).$suffix ?>" title="Next Page">&rsaquo;</a></li>
<li><a class="<? if($curPageIndex == $pagination->getPageCount()-1) : ?>disabled<? endif; ?>" href="<?= $base_url.'/'.$pagination->getPageCount().$suffix ?>" title="Last Page">&raquo;</a></li>
</ul>
</div>
<? endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment