トップページ >  CakePHP >  ページネーション
初版2009/12/02: 最終更新日2009/12/02
ページネーション
目次
ページネーションとは
ページ移動のリンクを出力する
ページ情報を出力する
ページネーションとは
ページネーションとは、複数に渡るページを移動する際に使用するナビゲーションであり、 GoogleやYahooの検索結果の下部などに表示されています。
ページ移動のリンクを出力する
次のページや前のページへのリンクを作成するにはprevメソッドやnextメソッドを使います。
	<?php echo $paginator->prev('<< 前のページへ');?>
	<?php echo $paginator->next('次のページへ >>');?>


prevメソッド/nextメソッドのオプション
title, option, disabledTitle, disabledOptionsなどを指定できます。
    * title(タイトル「例:次のページ」)
    * option(オプション)
    * disabledTitle(リンク無効時のタイトル)
    * disabledOptions(リンク無効時のオプション)
ページ情報を出力する
現在何ページ目かといった情報を表示するにはcounterメソッドを使います。
echo $paginator->counter(array(
'format' => '%page% / %pages% ページ,  全%count%件中%current%件, ( %start% から %end%)'
));
  出力例:

  "format" => "range"の出力例:
    【1 - 5 of 10】 ※%start% - %end% of $paging['count']
      ⇒[ of ]という文字は変更可能


  "format" => "pages"の出力例
    【1 of 10】
      ⇒[ of ]という文字は変更可能


  以外
    $out = str_replace(array_keys($replace), array_values($replace), $options['format']);

    '%page%'    => $paging['page']        現在ページ
    '%pages%'   => $paging['pageCount']   総ページ数
    '%current%' => $paging['current']     現在のページに表示しているデータの件数
    '%count%'   => $paging['count']       データの総件数
    '%start%'   => $start                 現在のページに表示しているデータの開始位置
    '%end%'     => $end                   現在のページに表示しているデータの終了位置