Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a list of avatars that needs to be sorted differently than they're being generated. It doesn't appear to be sorted by the name or date, so I'm wondering how they're even being sorted. If there's a way to sort them through the UI, that would be great, but I'm guessing I just need to add/change an 'ORDER BY' in the php, but I'm a novice at php, so I don't really know what I'd have to change.
Comments
Comment #1
stella CreditAttribution: stella commentedThere's currently no ordering of the avatars. They are simply selected out of the database. I'm not sure about other database systems, but in such cases MySQL will return them in the order that they were inserted. At the moment the only way to change the order would be to (a) rename all the files so that they are in the order you want (b) delete everything from the avatar_selection table and (c) then do a bulk upload on the avatar settings screen. This isn't ideal.
I rather like the idea of being able to change the order but we need to decide how best to implement it. One method would be to select all the files from the db ordered by name, but since you can't change the name of a file after it's been uploaded (without clearing the db table), then this probably isn't the best solution.
I think a better solution might be to add a new form or a new form option that allows you to assign a weight to an individual avatar. The tricky bit is in assigning a weight that applies across the various user roles that it is setup for.
Cheers,
Stella
Comment #2
stella CreditAttribution: stella commentedI've added this feature to the avatar selection module. You can now assign a name and a weight to each avatar. Sorting is done by the weight, name and then filename. If you have an avatar assigned to multiple roles/groups then you will need to keep that in mind when setting the weight value.
Please try the latest dev release (available later today) - you will also need to run update.php.
Cheers,
Stella
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #4
stella CreditAttribution: stella commentedReleased in Avatar Selection 5.x-2.6 and 6.x-1.4. Note, the 5.x-2.6 version is dependant on jQuery Update.
Cheers,
Stella