Drupal 7主题(''pager') - >表格被渲染但没有寻呼机?

Kar*_*ers 1 themes pager dynamicquery drupal-7

我有一个包含来自数据库的数据的表,我希望它有一个寻呼机,我有一个示例(buildamodule.com)和其他站点中的所有代码,我的表得到渲染,但它不生成寻呼机,虽然我有更多的行然后限制:

在此输入图像描述

功能:

function get_loyaltycodes(){
$headers = array(
    array(
        'data' => t('Code')
    ),
    array(
        'data' => t('Info')
    ),
    array(
        'data' => t('Points')
    ),
    array(
        'data' => t('Consumed by')
    ),
);
$limit = variable_get('codes_per_page',5);
$query = db_select('loyalty_codes','lc');
$query -> fields('lc',array('code','info','points','uid'))
       -> orderBy('lc.info','ASC')
       -> extend('PagerDefault')
       -> limit($limit);


 //to see all codes for a certain amount of points, just append the number of points to the URL    
 $arg = arg(2);
 if($arg != '' && is_numeric($arg))
 {
    $query->condition('points', $arg);
 }

// Fetch the result set.
 $result = $query->execute();
 $rows = array();
  // Loop through each item and add to the $rows array.
  foreach ($result as $row) {
    $rows[] = array(
        $row->code, 
        $row->info, 
        $row->points, 
        $row->uid, 
    );
  }

  // Format output.
  $output = theme('table', array('header' => $headers, 'rows' => $rows)) . theme('pager');

  return $output;
Run Code Online (Sandbox Code Playgroud)

$ limit变量在设置表单中设置为5,在数据库中也是5.

谁知道为什么寻呼机没有显示?也许在格式化输出的东西?

非常感谢帮助!

小智 5

显然我无法登录正确知道,因为我在防火墙后面,无论如何我似乎已经修复了它,但是愚蠢的错误:

‘->extend(‘PagerDefault’)查询中的扩展必须是菊花链中的第一个函数.如果不是没有错误,但似乎没有调用该函数.

$query = db_select('loyalty_codes','lc')
        ->extend('PagerDefault')
        -> fields('lc',array('code','info','points','uid'))
        -> orderBy('lc.info','ASC')
        -> limit(5);//$limit);
Run Code Online (Sandbox Code Playgroud)

  • 它不需要是链中的第一个函数(这也是我以前的想法)。请参阅 [this question](http://stackoverflow.com/questions/7637279/how-do-i-get-pagerdefault-queries-to-work-correctly-with-drupal-7) 的公认答案,该答案将其清除很好 (2认同)