List all entities contained by the container of the entity


I would like to get all tidypics' images which belong to a particular group. I can get all photos of the particular album in an easy way:

$params = array('types' => 'object', 'subtypes' => 'image', 'container_guid' => $album_guid);
$photos = elgg_get_entities($params);

but I can not of course get the images belonging to the group in this way, because the containers of all images are albums not groups. And the groups are containers of albums.

In other words I would like to get all images which are contained in all albums belonging to a particular group. How to accomplish this task? I can see that function elgg_get_entities has many possible options (like 'selects','wheres' and 'joins') but I can not find any good documentation with some examples of use.

I guess it is rather a simple problem. Could anyone help me?


  • Hey Rob, try grabbing all the of the albums belonging to a group ie: 

    $params = array('types' => 'object', 'subtypes' => 'album', 'container_guid' => $group_guid);

    Then you can grab the images within each album. There might be a more graceful way of doing the same with the wheres and joins, but I'm not a DB guru 

    - Jeff

  • Jeff, thanks for your reply. I will follow your advice temporarily - but it is rather a workaround not a real solution. I would like to know how to achieve this by using one function invocation :)


  • Register for the create image event (or whatever it is called). In your callback, check if the album (container) has a container of group. If so, create a relationship betwen photo and group.

    Now all you need to do is pull all photos that belong to the group using the relationship.