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.