The third episode of our "Customizing Frontend Applications" saga will be focused on pagination. Sooner or later each web developer/designer working on a web site will have to deal with contents pagination.
BEdita comes with an easy way to do it, allowing a default pagination setting for the entire frontend application and/or a specific one for each section you want.

Once again we'll use the FrontendController::$sectionOptions attribute, in particular we are interested in childrenParams key.

Overriding this class attribute in our PagesController we can set a default pagination for all our sections:

protected $sectionOptions = array(
   "showAllContents" => true,
   "itemsByType" => false,
   "childrenParams" => array(
      "order" => "title",
      "dim" => 10,
      "dir" => true


In this way we are saying to show 10 items for page sorted by title[1] in ascendant mode. Set dir to false to reverse the order of items. The couple "page" => 1 is implied but if you want to show your items starting from page 2 you can add it to childrenParams.

Change page, sort or page dimension is very very simple. We can use the named params convention used by CakePHP, so

will switch automagically to page 2 and similary we can change the order

the order direction

or several things at once

The only thing you can do it at this point is build your toolbar pagination and to do this you have a toolbar array available inside $section array, for example:


['toolbar'] => Array (
   ['first'] => 1
   ['prev'] => 1
   ['next'] => 3
   ['last'] => 5
   ['size'] => 9
   ['pages'] => 5
   ['page'] => 2
   ['dim'] => 2
   ['start'] => 3
   ['end'] => 4



  • first is equal to 0 if we are in the first page
  • prev is the previous page
  • next is the next page
  • last is the last page and is equal to 0 when we are in the last page
  • size is the total number of items
  • pages is the total number of pages available
  • page is the current page number
  • dim is the dimension of items for page
  • start is the numeric position of first current page's item
  • end is the numeric position of last current page's item

So you could build your own helper to show the pagination toolbar or you can use the BeToolbar helper of BEdita core.

Change the default pagination for a section

As usual (if you read the previous articles 1-2) you can change the default $sectionOptions["childrenParams"] attribute for a specific section thorugh out the section-nicknameBeforeFilter callback.

That's it.


[1] Note that "title" is a field of "objects" table used by BEObject model, so if you want to be sure to avoid ambiguous fields you should specify the model field you want to order by i.e. "order" => "BEObject.title". We'll see in other post how to filter the selection of items using "filter" key in "childrenParams". This filter can be build using fields of other tables that can collide with BEObject fields.