Search code examples
cakephpcoding-stylepagination

How do you style the paginator used in CakePHP with CSS?


How do you style the paginator with CSS used in CakePHP?

I can't find a way to attach a CSS class / ID to each of the "span" generated by the default pagination helper in CakePHP.


Solution

  • see: http://www.switchonthecode.com/tutorials/cakephp-part-6-pagination and https://book.cakephp.org/3/en/views/helpers/paginator.html

    What stands out here is that you can pass options to next(), prev(), and numbers()

    what you want to do is pass the class option.

    e.g.

      $paginator->prev(
        '<< Previous',
        array(
          'class' => 'PrevPg'
        ),
        null,
        array(
          'class' => 'PrevPg DisabledPgLk'
        )
      ).
      $paginator->numbers(
        array(
          'class' => 'numbers'
        )
      ).
      $paginator->next(
        'Next >>',
        array(
          'class' => 'NextPg'
        ),
        null,
        array(
          'class' => 'NextPg DisabledPgLk'
        )
      ),
      array(
        'style' => 'width: 100%;'
      )