显示类型组列表

时间:2011-08-24 08:54:31

标签: drupal drupal-entities

我已阅读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(..)中声明它,并添加一个新的视图模式'list'。

任何人都可以分享一个工作代码,用于显示带有寻呼机的实体列表吗?

P.S。我以小组为例,但我不介意任何其他类型的实体。

1 个答案:

答案 0 :(得分:0)

只是想一想,当你在对entity_view的调用中使用'full'而不是teaser时会发生什么?你有没有检查过类型'group'的teasers的显示模式实际上是否有一些字段要显示在其中?

相关问题