We have moved to Github. Please open tickets there.

Opened 3 years ago

Last modified 17 months ago

#2566 new Enhancement

Add wrapper functions for getting users, objects, and groups that join on that table so that the queries can be ordered by entity type specific columns

Reported by: mrclay Owned by:
Priority: normal Milestone: Near Term Future Release
Component: Core Version: 1.7
Severity: minor Keywords: ordering title
Cc: brettp Difficulty: easy

Description

This patch makes it easier to order entity queries by title by adding the necessary join:

$options['order_by'] => 'title'; // now possible
$entities = elgg_get_entities($options);

Attachments (1)

entities.php.patch (1.0 KB) - added by mrclay 3 years ago.
patched lib/entities.php from 1.7.4

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by mrclay

patched lib/entities.php from 1.7.4

comment:1 Changed 3 years ago by mrclay

Oops, that preg_replace pattern should be:

'/\b(e\.)?title\b/'

Point is to allow user to follow the convention of all order_by columns prefixed with "e.". This might not be a great idea.

comment:2 Changed 3 years ago by cash

I think it would be great if Elgg supported sorting by object title, group name, and user name without requiring the developer to write SQL clauses. Perhaps a convenience function to produce the options for elgg_get_entities()?

This patch mixes a convenience option (passing in title) with passing in SQL statements. I think that is a bad precedent. Though elgg_get_entities already mixes these, it hasn't done this with a single parameter.

Options:

  • add a sort parameter that handles mapping convenience options to SQL statements
  • change order_by to only accept convenience options
  • provide a convenience option for a developer to get the necessary SQL statement for a order_by

comment:3 Changed 3 years ago by ewinslow

Rels #2527. It doesn't make much sense to me to order by a property that not all of the rows will have, but if I know I just want objects, then it would make sense to join the objects table and allow filtering/sorting based on object-specific fields.

comment:4 Changed 3 years ago by cash

I like Evan's idea. Maybe we should look into this for Elgg 1.8 rather than 1.9 as currently marked on #2527. We get a lot of requests for getting an alphabetical list of groups, users, etc.

comment:5 Changed 3 years ago by ewinslow

Rels #2675 -- If we implement that, then we won't have to have multiple functions for ordering entities alphabetically depending on their type

comment:6 Changed 2 years ago by cash

  • Difficulty set to easy
  • Milestone changed from Needs Review to Elgg 1.8.1
  • Summary changed from allow easier title ordering in elgg_get_entities to Add wrapper functions for getting users, objects, and groups that join on that table so that the queries can be ordered by entity type specific columns

comment:7 Changed 17 months ago by cash

  • Milestone changed from Elgg 1.8.x to Near Term Future Release
Note: See TracTickets for help on using tickets.