concrete5 のページ送りの HTML を適度にお手軽かつ高度にカスタマイズする方法


concrete5 のページ送りを適度にカスタマイズする方法です。

Bootstrap ベースの場合

デフォルトの concrete5 のページ送りはこれです。
Bootstrap 3 ベースでページネーションが表示されます。

<?php if ($pagination) { ?>
    <?=$pagination ?>
<?php } ?>

Bootstrap3 のページネーションが表示されます。
オプションをいろいろ追加できます。

<?php if ($pagination) { ?>
    <?php
    $pagination = $list->getPagination();
    if ($pagination->getTotalPages() > 1) {
        $options = array(
            'proximity'           => 2,
            'prev_message'        => 'Go to previous',
            'next_message'        => 'Go to next',
            'dots_message'        => 'Dots',
            'active_suffix'       => 'Current Page',
            'css_container_class' => 'my-container-class',
            'css_prev_class'      => 'my-prev-class',
            'css_next_class'      => 'my-next-class',
            'css_disabled_class'  => 'my-disabled-class',
            'css_dots_class'      => 'my-dots-class',
            'css_active_class'    => 'my-active-class'
        );
        echo $pagination->renderDefaultView($options);
    }?>
<?php } ?>

参考: Bootstrap3で使えるオプション
https://github.com/whiteoctober/Pagerfanta#twitterbootstrapview-twitterbootstrap3view-and-twitterbootstrap4view

Bootstrap 以外のテンプレートで実装したい場合

Bootstrap ベース以外で独自に Wrapper とか作りたい場合があります。
https://github.com/whiteoctober/Pagerfanta#defaultview

if ($pagination) {
    $pagination = $list->getPagination();
    if ($pagination->getTotalPages() > 1) {
        $paginationView = new \Pagerfanta\View\DefaultView();
        $pagination = $paginationView->render($pagination, $pagination->getRouteCollectionFunction(), [
            'proximity' => 3,
            'prev_message' => 'もどる',
            'next_message' => '',
            'container_template' => '<div id="links">%pages%</div>',
            'span_template'      => '<b class="%class%">%text%</b>'
        ]);
        echo $pagination;
    }
}

参考: DefaultView で使えるオプション & デフォルト値
https://github.com/whiteoctober/Pagerfanta#defaultview

これで、Bootstrap 以外のページネーションを生成できます!