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: https://i.stack.imgur.com/VKRlW.png).
I can’t seem to find anything on the Cookbook that mentions anything that would fix this.
Can this even be fixed?
All you really need to do is add a CSS class for the current and disabled items to match. Here’s one I use for my project (it’s basically copied and pasted from the bootstrap CSS file).
This gives it the same style as the
atags.