3

In the administrator area of Joomla 3.6.x the User Manager has a number of filters to change the sorting of users. I always want the most recently registered users to appear on top without having to select that option (Registration Date). Is there a way to force the selection, perhaps with an override? Thanks.

1

Override the file administrator/components/com_users/views/users/tmpl/default.php (e.g. copy it to administrator/templates/[your-admin-template]/com_users/users/default.php)

Change the following 2 lines:

$listOrder  = $this->escape($this->state->get('list.ordering'));
$listDirn   = $this->escape($this->state->get('list.direction'));

to:

$listOrder  = 'a.registerDate';
$listDirn   = 'DESC';

Save the file, and then clear your Joomla cache.

Note: The above override will cause the ordering to be always by last registration date, even if you choose another ordering (in other words, the ordering will be hardcoded).

  • I'm sure a more elegant approach could be found that has a default but also takes change into account. It's an override after all. – BodgeIT Nov 18 '16 at 18:08
0

I know this is a fairly old question but it comes up in Google when searching for "Joomla default sort" and so I'd like to add a more definitive answer.

The default ordering for most of the Joomla backend manager pages (Menu manager, User manager, Article manager, Featured Article manager, Category manager, etc) are all part of Joomla core files that can't be modified via Joomla's template override functionality.

Ie, if you want to be able to modify the default ordering without losing the ability to change the sort order (the issue with itoctopus' answer) then you'll be forced to make core edits.

For each manager page the core edits are very similar. You need to modify two files:

/administrator/components/<component>/models/forms/filter_<view>.xml

and

/administrator/components/<component>/models/<view>.php

I'll use the User manager as an example (since that's what this question is asking about specifically):

Open

/administrator/components/com_users/models/forms/filter_users.xml

and find the "fullordering" field. Modify the "default" attribute from "a.name ASC" to "a.registerDate DESC" (or whatever you want the new default to be). This change will result in the drop-down select menu on the page to show that new value as the default when the page loads.

Then open

/administrator/components/com_users/models/users.php

and find the populateState() method:

protected function populateState($ordering = 'a.name', $direction = 'asc')

Change those default parameter values to what you want:

protected function populateState($ordering = 'a.registerDate', $direction = 'desc')

This change is what results in the default ordering being different.


In the same way, if you wanted the "Featured Articles" manager to order by "Start Publishing" date by default you'd follow the same steps:

Open

/administrator/components/com_content/models/forms/filter_featured.xml

and change the "default" attribute of the "fullordering" field to "a.publish_up DESC"

Then open

/administrator/components/com_content/models/featured.php

and change the parameters of the populateState() method:

protected function populateState($ordering = 'a.publish_up', $direction = 'desc')

As always, since this is core edit any Joomla updates may undo these changes and so you'll have to check for this and re-apply the changes if needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.