Created
April 18, 2014 18:42
-
-
Save juizmill/11058532 to your computer and use it in GitHub Desktop.
partials/paginator.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$urlPattern = $_SERVER['REQUEST_URI']; | |
$formatUrl = function ($page) use ($urlPattern) { | |
if (!preg_match('/page/', $urlPattern)) | |
return $urlPattern . '/page/' . (int) $page; | |
else | |
return preg_replace('@/page/(\d+)@', '/page/' . (int) $page, $urlPattern); | |
}; | |
?> | |
<?php if ($this->pageCount > 1): ?> | |
<p class="text-info">Pagina <strong class="text-danger"><?php echo $this->current;?></strong> de <strong class="text-danger"><?php echo $this->pageCount;?></strong></p> | |
<ul class="pagination pagination-sm"> | |
<?php if (isset($this->previous)): ?> | |
<li><a class="tooltips" href="<?php echo $formatUrl($this->previous) ?>" data-toggle="tooltip" data-placement="top" title="Ir para pagina anterior"><i class="glyphicon glyphicon-circle-arrow-left"></i></a></li> | |
<?php else: ?> | |
<li class="disabled"><a class="tooltips" href="" onclick="return false;" data-toggle="tooltip" data-placement="top" title="Ir para pagina anterior"><i class="glyphicon glyphicon-circle-arrow-left"></i></a></li> | |
<?php endif; ?> | |
<?php foreach ($this->pagesInRange as $page): ?> | |
<?php if ($page != $this->current): ?> | |
<li><a href="<?php echo $formatUrl($page); ?>"><?php echo $page; ?> </a></li> | |
<?php else: ?> | |
<li class="active"><a href=""><?php echo $page; ?> </a></li> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
<?php if (isset($this->next)): ?> | |
<li><a class="tooltips" href="<?php echo $formatUrl($this->next); ?>" data-toggle="tooltip" data-placement="top" title="Ir para próxima pagina"><i class="glyphicon glyphicon-circle-arrow-right"></i></a></li> | |
<?php else: ?> | |
<li class="disabled"><a class="tooltips" href="" onclick="return false;" data-toggle="tooltip" data-placement="top" title="Ir para próxima pagina"><i class="glyphicon glyphicon-circle-arrow-right"></i></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