2

I have a pager missing from one page, while visible on another. These pages are generated by my custom module. I'm working with a custom theme that's been hacked together (wasn't me!) When I switch the theme to Bartik everything works as expected.

Here is the query function:

function query_activities($tid = NULL, $did = NULL) {
  $record_count = variable_get('promo_list_count');
  $query = db_select('node', 'n')->extend('PagerDefault');
  $query->fields('n', array('nid', 'title'));
  if ($tid) {
    $query->leftJoin('taxonomy_index', 'ti', 'ti.nid = n.nid');
    $query->condition('ti.tid', $tid);
  }
  $query->condition('n.type', 'activity_promo_list');
  $query->condition('n.status', 1);
  $query->groupBy('n.nid');
  $query->orderBy('n.sticky', 'DESC');
  $query->orderBy('n.promote', 'DESC');
  $query->orderBy('n.changed', 'DESC');
  $query->orderBy('n.created', 'DESC');
  $query->limit($record_count);
  $results = $query->execute()->fetchAll();
  return $results;

I have a function that wraps the query results in theme arrays and can post the whole thing if needed (it's 120 lines) but I think the only relevant part is:

  $content['pager'] = array(
  '#theme' => 'pager',
  '#weight' => $count,
  '#quantity' => 5,
  );
  krumo($content['pager']);
  return $content;

The krumo() dump shows the pager array populated on both pages (pager visible & pager missing).

Does this narrow the problem to theme layer?

What should I look for to fix or diagnose the missing pager?

  • It's (almost) definitely a theme layer problem, does the hacked-together-theme contain a function called THEMENAME_pager? – Clive Mar 13 '12 at 18:12
  • No, I saw a few other questions refer to THEMENAME_pager, so I searched for this (actually searched pager) and nothing out of the ordinary came up. – Merrick Mar 13 '12 at 18:51
  • How does your module generate and pass the pager to the page? – sheena_d Mar 13 '12 at 19:27
  • @sheena_d I updated the question to include some code :) – Merrick Mar 13 '12 at 21:32
  • have you looked at the HTML source of the page as outputted to a browser? Is the pager markup there? .. just thinking it could be as simple as a CSS rule. – jdu Apr 4 '12 at 19:59
0

I stumbled on tostinni's answer in Pager disappears when adding "GROUP BY" in the SQL query.

Your query with the GROUP BY is incorrect, MySQL is lax enough to let you write this kind of queries but it is by no way recommended. When you use a GROUP BY clause you should group all the columns without a aggregate function.

I then fixed two queries that have poorly formed GROUP BYs, but my pager was still missing. I bust out Devel's query logging feature; the offending SQL query resulted to be used by the Nodequeue module. I checked the bug reports for that module, and found the one about that query: Grouping error" when creating a simple queue (PostgreSQL).

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.