Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay a list of type group
    text
    copied!<p>I have read the <a href="http://www.istos.it/blog/drupal/drupal-entities-part-1-moving-beyond-nodes" rel="nofollow">tutorial</a>, and the API, looked through the code <a href="http://drupal.org/project/examples" rel="nofollow">examples</a>. But when it came down to implementation, it didn't work as i thought it would.<br> I am trying to avoid using the Views module for now, just for learning purposes.</p> <pre><code>function mymodule_menu() { $items['groups'] = array( 'title' =&gt; t('Groups list'), 'page callback' =&gt; 'mymodule_groups_overview', 'access callback' =&gt; TRUE ); return $items; } function mymodule_groups_overview() { $build = array(); $query = db_select('og', 'og')-&gt;extend('PagerDefault'); $query-&gt;fields('og', array('gid')); $result = $query -&gt;limit(10) -&gt;orderBy('og.gid') -&gt;execute(); if ($result) { $gids = $result-&gt;fetchCol(); $entities = og_load_multiple($gids); $build = entity_view('group', $entities, 'teaser'); } return $build; } </code></pre> <p>The problem is that <code>entity_view(..)</code> returns nothing, and <code>og_load_multiple(..)</code> returns an array of entities, but there is no content and no fields.</p> <p>If this worked, I would probably override the controller, declare it in <code>mymodule_entity_info_alter(..)</code>, and added a new view mode 'list'.</p> <p>Can anyone please share a working code for displaying a list of entities with a pager?</p> <p>P.S. I took the groups for example but i dont mind any other type of entities.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload