-
-
Save luisuribe/3299469 to your computer and use it in GitHub Desktop.
Paging Element for Twitter Bootstrap and CakePHP 2.0+
This file contains hidden or 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 $span = isset($span) ? $span : 8; ?> | |
<?php $page = isset($this->request->params['named']['page']) ? $this->request->params['named']['page'] : 1; ?> | |
<div class="pagination"> | |
<ul> | |
<?php echo $this->Paginator->prev( | |
'← ' . __('Previous'), | |
array( | |
'escape' => false, | |
'tag' => 'li' | |
), | |
'<a onclick="return false;">← Previous</a>', | |
array( | |
'class'=>'disabled prev', | |
'escape' => false, | |
'tag' => 'li' | |
) | |
);?> | |
<?php $count = $page + $span; ?> | |
<?php $i = $page - $span; ?> | |
<?php while ($i < $count): ?> | |
<?php $options = ''; ?> | |
<?php if ($i == $page): ?> | |
<?php $options = ' class="active"'; ?> | |
<?php endif; ?> | |
<?php if ($this->Paginator->hasPage($i) && $i > 0): ?> | |
<li<?php echo $options; ?>><?php echo $this->Html->link($i, array("page" => $i)); ?></li> | |
<?php endif; ?> | |
<?php $i += 1; ?> | |
<?php endwhile; ?> | |
<?php echo $this->Paginator->next( | |
__('Next') . ' →', | |
array( | |
'escape' => false, | |
'tag' => 'li' | |
), | |
'<a onclick="return false;">Next →</a>', | |
array( | |
'class' => 'disabled next', | |
'escape' => false, | |
'tag' => 'li' | |
) | |
);?> | |
</ul> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment