- <?php
- * @file
- * Hook implementations for the Pager Example module.
- */
-
- * @defgroup pager_example Example: Pager
- * @ingroup examples
- * @{
- * This example demonstrates a page with content in a pager.
- *
- * This is an example showing how a module can implement a pager in order to
- * reduce the number of output rows to the screen, and allow a user to scroll
- * through multiple screens of output.
- *
- * See PagerDefault.
- */
-
- * Implements hook_menu().
- */
- function pager_example_menu() {
- $items['examples/pager_example'] = array(
- 'title' => 'Pager Example',
- 'description' => 'Show a page with a long list across multiple pages',
- 'page callback' => 'pager_example_page',
- 'access callback' => TRUE,
- );
- return $items;
- }
-
- * Builds the pager.
- *
- * Uses the menu_links table since it is installed with several rows in it and
- * we don't have to create fake data in order to show this example.
- *
- * @return array
- * A render array completely set up with a pager.
- */
- function pager_example_page() {
-
- $header = array(
- array('data' => t('MLID')),
- array('data' => t('Link title')),
- array('data' => t('Menu name')),
- );
-
-
-
-
- $query = db_select('menu_links', 'm')->extend('PagerDefault');
- $query->fields('m', array('mlid', 'link_title', 'menu_name'));
-
-
-
- $result = $query
- ->condition('m.link_title', '', '<>')
- ->limit(10)
- ->orderBy('m.mlid')
- ->execute();
-
- $rows = array();
- foreach ($result as $row) {
-
-
-
- $rows[] = array('data' => (array) $row);
- }
-
-
-
- $build['pager_table'] = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#empty' => t('There are no date formats found in the db'),
- );
-
-
- $build['pager_pager'] = array('#theme' => 'pager');
-
- return $build;
- }
- * @} End of "defgroup pager_example".
- */