Order by with elgg_get_entities function doesn't work

I have a problem with 'order by' on elgg_get_entities(). Because this doesn't work, i mean, i set this to order by title but it doesn't work for me and i was trying with elgg_get_entities_from_metadata function.

Any body can help me with that?

this is my peace of code:

$calendars = elgg_get_entities_from_metadata(array(

      'types' => 'object',

      'subtypes' => '3key_calendar',

      'owner_guid' => $owner->guid,

      'container_guids' => $owner->guid,

      'order by' => array('name' => 'title', 'direction' => ASC, 'as' => text)

   ));

  • Title is not stored as metadata, it is part of the core objects_entity table. You'll have to use a custom join and order_by clause. Something like this (untested):

    $calendars = elgg_get_entities_from_metadata(array(

          'types' => 'object',

          'subtypes' => '3key_calendar',

          'owner_guid' => $owner->guid,

          'container_guids' => $owner->guid,

          'joins' => array("INNER JOIN {$CONFIG->dbprefix}objects_entity o ON (e.guid = o.guid)"),

          'order_by' => 'o.title'

       ));

  • Thank Andras... this code works for me now... thanks a lot