首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Drupal7主题(‘’Pager‘) ->表格get已呈现,但没有Pager?

Drupal7主题(‘’Pager‘) ->表格get已呈现,但没有Pager?
EN

Stack Overflow用户
提问于 2012-03-08 16:07:20
回答 1查看 6.5K关注 0票数 1

我有一个包含来自数据库的数据的表,我希望它有一个分页程序,我有来自其他站点的示例( buildamodule.com)的所有代码,并且我的表get被呈现,但它不生成分页程序,尽管我有比限制更多的行:

函数:

代码语言:javascript
复制
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。

有人知道为什么寻呼机没有显示吗?也许是输出的格式化中的一些东西?

非常感谢您的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-08 16:51:20

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

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

代码语言:javascript
复制
$query = db_select('loyalty_codes','lc')
        ->extend('PagerDefault')
        -> fields('lc',array('code','info','points','uid'))
        -> orderBy('lc.info','ASC')
        -> limit(5);//$limit);
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9614549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档