Set download folder when using FAL in TCA

Can I use FAL to set the download destination folder directly in the TCA column? My configuration looks like this:

'images_outdoor' => Array ( 'exclude' => 1, 'label' => 'Outdoor: ', 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('images_outdoor', Array ( 'appearance' => Array ( 'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference' ), 'minitems' => 1, 'maxitems' => 6, ), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), ), 

I have such columns in different TCAs and want their images to be saved in different folders. Therefore, the standard folder setting does not work here.

+5
source share
1 answer

I know this one is old, but here is the answer.

There is no supported method for TYPO3 6.2, but in the new TYPO3 7.6 LTS it should be possible to register the hook in your ext_localconf.php file, add this:

 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getDefaultUploadFolder'][] = 'VendorName\ExtensionName\Hooks\BackendUserAuthentication->getDefaultUploadFolder' 

Create a Classes/Hooks/BackendUserAuthentication.php and write something like this:

 <?php namespace VendorName\ExtensionName\Hooks; classe BackendUserAuthentication { public function getDefaultUploadFolder(Array $params, \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUserAuthentication) { // Do what you wants here and return a object of \TYPO3\CMS\Core\Resource\Folder } } 

The params array will indicate the following:

 $_params = array( 'uploadFolder' => $uploadFolder, // The current \TYPO3\CMS\Core\Resource\Folder object, properly 1:/user_upload/ 'pid' => $pid, // Page id 'table' => $table, // The table name 'field' => $field, // The field name ); 

Now use the name of the table and fields to change the download folder - good look :)

+1
source

Source: https://habr.com/ru/post/1208818/


All Articles