Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap pagination with CakePHP pagination helper

I'm trying to get CakePHP's pagination helper to play nicely with bootstrap. That is, I want my pagination elements to look like bootstrap's but generated by CakePHP.

At the moment I've got this on my view page:

<?php echo $this->Paginator->numbers(array(     'before' => '<div class="pagination"><ul>',     'separator' => '',     'currentClass' => 'active',     'tag' => 'li',     'after' => '</ul></div>' )); ?> 

Which produces the following markup:

<div class="pagination">     <ul>         <li class="active">1</li>         <li><a href="/test/posts/page:2">2</a></li>         <li><a href="/test/posts/page:3">3</a></li>     </ul> </div> 

The problem is, because the active page (1 in this case) doesn't have an <a> element in the <li> tag, it's not displaying correctly on the page (see here: http://i.imgur.com/OczPh.png).

I can't seem to find anything on the Cookbook that mentions anything that would fix this.

Can this even be fixed?

like image 880
James Dawson Avatar asked Jan 15 '13 20:01

James Dawson


1 Answers

I've used the generic functions of cake php html needed to bootstrap.

Gist code: https://gist.github.com/jruzafa/5302941

<div class="pagination pagination-large">     <ul class="pagination">             <?php                 echo $this->Paginator->prev(__('prev'), array('tag' => 'li'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));                 echo $this->Paginator->numbers(array('separator' => '','currentTag' => 'a', 'currentClass' => 'active','tag' => 'li','first' => 1));                 echo $this->Paginator->next(__('next'), array('tag' => 'li','currentClass' => 'disabled'), null, array('tag' => 'li','class' => 'disabled','disabledTag' => 'a'));             ?>         </ul>     </div> 
like image 118
jruzafa Avatar answered Oct 02 '22 02:10

jruzafa