【问题标题】:Drupal 7 theme(''pager') -> table get's rendered but without Pager?Drupal 7 主题(''pager')-> 表得到渲染但没有 Pager?
【发布时间】:2012-03-08 08:07:19
【问题描述】:

我有一个包含来自数据库的数据的表,我希望它有一个寻呼机,我拥有来自其他站点的示例(buildamodule.com)的所有代码,并且我的表已呈现,但它没有t 生成寻呼机,尽管我的行数超过了限制:

功能:

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;

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

有人知道为什么寻呼机没有显示吗?也许输出格式中的某些内容?

非常感谢您的帮助!

【问题讨论】:

    标签: drupal-7 themes pager dynamicquery


    【解决方案1】:

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

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

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

    【讨论】:

    • 它不需要是链中的第一个函数(这也是我以前的想法)。请参阅this question 的已接受答案,它可以很好地清除它
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-31
    • 2012-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-08
    相关资源
    最近更新 更多