I am studying the pager_example in example module.
When creating an render array, it first assign #theme as 'table'. But it assign the #theme as 'pager' just before returning.

What is the purpose of attach the pager theme ?


// Create a render array ($build) which will be themed as a table with a
// pager.
$build['pager_table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
  '#empty' => t('There are no date formats found in the db'),

// attach the pager theme
$build['pager_pager'] = array('#theme' => 'pager');  <---- why need this ?
return $build[];

Then I remove the coding "$build['pager_pager'] = array('#theme' => 'pager');". The result is the same.

When compare to tablesort_example.module, it don't have attach the pager theme before the return.


// build the table for the nice output.
$build['tablesort_table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,

return $build;

The code $build['pager_pager'] = array('#theme' => 'pager'); returns the pager for the table.

The example module output with that line of code:

enter image description here

The example module output without that line of code:

enter image description here

If you are not seeing the same difference I am, it might be a cache issue, try clearing your cache between changes.

  • Thx Scott. You are awesome. I find the different after clearing the cache. – Matt Oct 1 '13 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.