[support] Drupal 7 Entities: Display a list of type group
Buratino
x9nx at mail.ru
Wed Aug 24 09:14:07 UTC 2011
I have read the tutorial, and the API, looked through the code examples.
But when it came down to implementation it didn't work as i thought it would.
Please help. I am trying to avoid using the Views module for now, just for learning purposes.
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;
}
The problem is that entity_view(..) returns nothing, and og_load_multiple(..) returns array of entities but there is no content and no fields.
If this worked, i would probably override the controller, with clans_pages_entity_info_alter(..), and added a new view mode 'list'.
Can someone please share a working code for displaying a list of entities with a pager? Thanks.
P.S. I took the groups for example but i dont mind any other type of entities.
--
Современная мобильная почта - для смартфонов и телефонов.
Оцените мобильный m.mail.ru с Вашего телефона
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20110824/51e41e13/attachment-0001.html
More information about the support
mailing list