How to use Zurb Foundation Pagination in CakePHP 2.x

The code below is a simple snippet that will allow you to implement or use Zurb Foundation pagination in CakePHP 2.x.



Create a new element and name it pagination.ctp. Copy the code below to pagination.ctp

<ul class="pagination">

    <?php

    echo $this->Paginator->prev('&laquo',

        array(

            'tag'=>'li',

            'disabledTag'=>'a',

            'escape'=>false

        ));

    echo $this->Paginator->numbers(array(

        'tag'=>'li',

        'separator'=>'',

        'currentTag'=>'a'

    ));

    echo $this->Paginator->next('&raquo',

        array(

            'tag'=>'li',

            'disabledTag'=>'a',

            'escape'=>false

        ));

    ?>

</ul>

<script>

    $('a:not([href]').parent().addClass('unavailable');

</script>



Use the element you created by invoking
<?php echo $this->element('pagination'); ?>
to any view that has a pagination involved.

Note: You have to include the Zurb Foundation Pagination CSS in order for this to work.

Labels: ,