I've following custom template for pagination links
<li class="prev"><a href="#">prev</a></li>
<li><a href="#" class="active">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">6</a></li>
<li><a href="#">7</a></li>
<li><a href="#">8</a></li>
<li>...</li>
<li><a href="#">30</a></li>
<li class="next"><a href="#">next</a></li>
I've tried it by using following code(cakephp 2.3 version
) but not getting the result as required.
<?php
echo $this->Paginator->prev('<', array( 'class' => '', 'tag' => 'li' ), null, array('class' => 'prev', 'tag' => 'li'));
echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => '', 'currentClass' => 'active', 'currentTag' => 'a' ));
echo $this->Paginator->next('>', array('class' => 'next', 'tag' => 'li' ), null, array( 'class' => 'next', 'tag' => 'li'));
?>
Please help me out to get it done.. Thanks in advance.
This is just a sample of my custom template for pagination links, that I made for use with bootstrap. You can modify it accordingly to your needs
<ul>
<?php
echo $this->Paginator->first('‹', array('tag' => 'li', 'title' => __('First page'), 'escape' => false));
echo $this->Paginator->prev('«', array('tag' => 'li', 'title' => __('Previous page'), 'disabledTag' => 'span', 'escape' => false), null, array('tag' => 'li', 'disabledTag' => 'span', 'escape' => false, 'class' => 'disabled'));
echo $this->Paginator->numbers(array('separator' => false, 'tag' => 'li', 'currentTag' => 'span', 'currentClass' => 'active'));
echo $this->Paginator->next('»', array('tag' => 'li', 'disabledTag' => 'span', 'title' => __('Next page'), 'escape' => false), null, array('tag' => 'li', 'disabledTag' => 'span', 'escape' => false, 'class' => 'disabled'));
echo $this->Paginator->last('›', array('tag' => 'li', 'title' => __('First page'), 'escape' => false));
?>
</ul>
The ellipsis ...
is created automatically by Paginator::numbers()
according to the CakeBook, but you can change it to whatever you want.
I hope it works out for you
来源:https://stackoverflow.com/questions/18181340/creating-pagination-with-cakephp-for-custom-template-links