default_sortby

default_sortby
Path

$GLOBALS['TCA'][$table]['ctrl']

Type

string

Scope

Display

If a field name for sortby is defined, then this is ignored.

Otherwise this is used as the 'ORDER BY' statement to sort the records in the table when listed in the TYPO3 backend. It is possible to have multiple field names in here, and each can have an ASC or DESC keyword. Note that the value should not be prefixed with 'ORDER BY' in itself.

Examples

Sort by title:

'ctrl' => [
   'default_sortby' => 'title',
   ...
],

Sort by title and then by creation date:

'ctrl' => [
   'default_sortby' => 'title ASC, crdate DESC',
   ...
],

Warning

Do not confuse this property with sortby: default_sortby should be set only if there is no sortby. The sortby field (typically set to sorting) contains an integer for explicit sorting , the backend then shows "up" and "down" buttons to manage sorting of records relative to each other. The default_sortby should only be set if that explicit sorting is not wanted or useful. For instance, the list of frontend users is sorted by username and has no other explicit sorting field in the database.