Skip to main content
1 of 2

Query pager not showing for administrator

I am having an interesting problem with paging the results of a query. The pager is visible to all users except those who are assigned the built-in 'administrator' role. I have tried the code on two separate Drupal installs and the result is the same: the administrator cannot see the pager. The markup is not visible in the page source.

I have tried my solution using both EntityFieldQuery and db_select, but the problem persists. Here is the code for the EntityFieldQuery version:

function build_area_table() {
  $header = array(
    'area_name' => array(
      'data' => 'Area',
      'type' => 'property',
      'specifier' => 'title',
      'sort' => 'asc',
    ),
    'level_range' => array(
      'data' => 'Level range',
      'type' => 'field',
      'specifier' => array('field' => 'field_area_level_range', 'column' => 'value'),
      'sort' => 'desc',
    ),
  );

  $query = new EntityFieldQuery();
  $query = $query->pager(5); # I have more than 5 rows being returned
  $query = $query->entityCondition('entity_type', 'node')
    ->propertyCondition('type', 'area')
    ->propertyCondition('status', 1)
    ->tableSort($header);

  $result = $query->execute();

  $nodes = null;
  // $result['node'] contains a list of nids where the title matches
  if (!empty($result['node'])) {
    // You could use node_load_multiple() instead of entity_load() for nodes
    $nodes = node_load_multiple(array_keys($result['node']));
  }

  // do something to output your results here.
  $td = array();
  foreach ($nodes as $area) {
    $td[] = array(
      'area_name' => array(
        'data' => l($area->title, 'node/'. $area->nid),
        'class' => array('area-name'),
        ),
        'level_range' => array(
          'data' => $area->field_area_level_range['und'][0]['safe_value'],
          'class' => array('level-range'),
        ),
    );
  }

  $areaTable = array(
    'area-table' => array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $td,
      '#empty' => 'No areas to display.',
    ),
    'area-pager' => array(
      '#markup' => theme('pager')
    ),
  );
  
  return $areaTable;
}

The table is rendered using Drupal 'render' in the template page. Does anyone have any ideas as to what the problem may be? I have read some posts regarding changing the pager ID, but any changes I make do not seem to have any effect.

Thanks!