Does The groups_Entity variables (ge.name) not work with regular sort?

To keep it quick and simple im having issues getting this sort mechanic down

$Order = "ge.name";

$GroupArray = elgg_get_entities(array(

'type' => 'group',

'order_by' => $Order . " " . $Sort,

'joins' => 'JOIN ' . $db_prefix . 'groups_entity ge',

'limit' => 10,

'pagination' => true,

'offset' => $Offset,

));

$Sort comes in either asc, or desc respectively, but it still doesnt sort it at all, while say using e.time_created does. Is there any reason for this and is there a possible work around?

(Using 1.8)

  • How about this?

    $GroupArray = elgg_get_entities(array(
        'type' => 'group',
        'joins' => array("JOIN {$db_prefix}groups_entity ge ON ge.guid = e.guid"),
        'order_by' => "ge.name" . " " . $Sort,
        'limit' => 10,
        'offset' => $Offset,
    ));

    You might want to refer to http://reference.elgg.org/1.8 sometimes. You can search for Elgg API functions and get the parameter list with some brief info. For example the 'joins' option expects an array. Also, the elgg_get_entities_*() functions make no use of the pagination option. That's for use with the elgg_list_entities_*() functions that return formatted output.

    The join clause of yours was incomplete. If you have no connection between the elgg_get_entities() call for groups and the additional join you just get all group entities.

  • It makes me feel silly that I did not think of this seeing as I use those types of arrays for the several other get_entities I use. However this works wonderfully and completely solves my issue, thanks!