So, I have been looking around and working with Elgg 1.8 for quite some time now, and while I am getting the hang of it, I am still a complete novice.
I have had this idea to sort my table which grabs certain information from elgg itself, specifically the groups and such. I want to sort everything by its tabs (name, total, difference, date) and for name and date elgg has been rather straight forward with that. However, I am not quite sure if I can do the same with the total and difference because of that. Take note of the code below.
$GroupArray = elgg_get_entities(array(
'type' => 'group',
//try to get this to use the order of the totalmembers
'order_by' => $Order . " " . $Sort,
'joins' => 'JOIN ' . $db_prefix . 'groups_entity ge',
'limit' => 10,
'pagination' => true,
'offset' => $Offset,
));
This $GroupArray captures all of the group stats which allows me to add all of the necessary information into the table, and the $Order and $Sort variables are dynamically added by clicking on the tabs in the table. Name and Date are already initialized in elgg with ge.name and e.time_created, but I need to do some trickery to get the members and total working the same way.
$TotalMembers = elgg_get_entities_from_relationship(array(
'relationship' => 'member',
'relationship_guid' => $Reports->guid,
'inverse_relationship' => true,
'type' => 'user',
'limit' => 20,
'joins' => array("JOIN {$db_prefix}users_entity u ON e.guid=u.guid"),
'order_by' => 'u.name ASC',
'count' => true,
'relationship_created_time_lower'
));
This is how I get the total amount of members for each column and group, it comes after the group array as that is what allows it to be grabbed. My issue now is trying to that the $TotalMembers 'order_by' to be put into the $Order variable, essentially sorting by the min to max total members for each group.
I have searched far and wide to no avail, and im not sure if my idea is plausible or if it even works as I think it can.
Is anyone able to give me a push in the right direction?
Well, it turns out it is possible, you just need to take apart Elgg's code and replace it with the Sql would otherwise create for you
This just takes the two different elgg statements which are really sql statements and joins them together so that it is now possible to search by the max avaliable for the total members query.