【问题标题】:Display a list of type group显示类型组列表
【发布时间】:2011-08-24 08:54:31
【问题描述】:

我已阅读 tutorial 和 API,查看了代码 examples。 但是当它落实到执行时,它并没有像我想象的那样工作。
我现在尽量避免使用 Views 模块,仅用于学习目的。

function mymodule_menu() {
  $items['groups'] = array(
    'title' => t('Groups list'),
    'page callback' => 'mymodule_groups_overview',
    'access callback' => TRUE
  );

  return $items;
}

function mymodule_groups_overview() {
  $build = array();

  $query = db_select('og', 'og')->extend('PagerDefault');
  $query->fields('og', array('gid'));

  $result = $query
    ->limit(10)
    ->orderBy('og.gid')
    ->execute();    

  if ($result) {
    $gids = $result->fetchCol();
    $entities = og_load_multiple($gids);    
    $build = entity_view('group', $entities, 'teaser');
  }

  return $build;
}

问题是entity_view(..)什么都不返回,og_load_multiple(..)返回一个实体数组,但是没有内容也没有字段。

如果这可行,我可能会覆盖控制器,在mymodule_entity_info_alter(..) 中声明它,并添加一个新的视图模式“列表”。

谁能分享一个用寻呼机显示实体列表的工作代码?

附:我以组为例,但我不介意任何其他类型的实体。

【问题讨论】:

    标签: drupal drupal-entities


    【解决方案1】:

    只是想一想,当您在对 entity_view 的调用中使用“完整”而不是预告片时会发生什么?您是否检查过“组”类型的预告片的显示模式实际上有一些要显示的字段?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多