Jump to the content of the page

TYPO3-Tutorial:descending order for file links

(Kopie 1)

Files can be made available for download in TYPO3 with the “uploads” content element. The order, whether according to file name, file size or file type, is always ascending.

If you would like to expand the functionality so that downloads can also be displayed in descending order, this can be done with just a few minor configurations.

This is how it’s done

The “uploads” content element uses the data processorTYPO3\CMS\Frontend\DataProcessing\FilesProcessor. It already contains a query for the ordering. All that needs to be done is extend the back end by inserting a select box to dynamically transfer the relevant value to the class using TypoScript.

1. Add the field to the database:

 CREATE TABLE tt_content ( 
   filelink_sorting_direction tinyint(1) unsigned DEFAULT '0' NOT NULL, 

2. Expand the $TCA:

   // Add new TCA field to the table "tt_content"
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', [
   'filelink_sorting_direction' => [
     'label' => 'Direction:',
     'config' => [
       'type' => 'select',
       'renderType' => 'selectSingle',
       'items' => [
         ['Ascending', 0],
         ['Descending', 1],
       'size' => 1,
       'maxitems' => 1,
       'eval' => '',
       'default' => 0
   // Add the field "filelink_sorting_direction" to the TCA palette "uploads"
 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette('tt_content', 'uploads', 'filelink_sorting_direction', 'after:filelink_sorting'); 

3. Extend TypoScript:

   # set the sorting direction
 tt_content.uploads.dataProcessing.10.sorting.direction = descending 
 tt_content.uploads.dataProcessing.10.sorting.direction.if.isTrue.field = filelink_sorting_direction 
Jump up Hide the menu