How to order entities by title on Elgg

By default, while developing in Elgg, when we use elgg_get_entities or elgg_get_entities_from_metadata we get entities sorted by time_created. But very often we need sort entities in another way such as by title.

In this case we can to use code below for getting entities of subtype "subtype_entity":

$dbprefix = elgg_get_config('dbprefix');
$options = array(
  'type' => 'object',
  'subtype' => 'subtype_entity',
  'full_view' => false,
  'joins' => array("INNER JOIN {$dbprefix}objects_entity o ON (e.guid = o.guid)"),
  'order_by' => 'o.title'

$entities = elgg_get_entities_from_metadata($options);




Shopping Cart

Your cart is empty.