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?
For bootstrap 2 with font awesome and full pagination you can use that :
And add a little hack to your css or less
This is actually specifically mentioned in the "Creating page number links" section of the "Paginator" documentation:
In your case, you'll want to use
'currentTag' => 'a'
. However, keep in mind that this option was added in CakePHP 2.3, so if you're using a version older than that, it won't work.You need to add an anchor tag between "li" tags for active page, try this code :
I've used the generic functions of cake php html needed to bootstrap.
Gist code: https://gist.github.com/jruzafa/5302941
The best I could get:
PHP:
CSS:
Result: