Set Upload Folder when using FAL in TCA

巧了我就是萌 提交于 2019-12-09 06:21:52

问题


Is it possible when using FAL, to set the upload destination folder directly in the TCA column? My configuration looks like this at the moment:

'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. So a standard folder setting doesn't work here.


回答1:


I know this one is old but here is a answer.

There are no supported way for TYPO3 6.2, but in the new TYPO3 7.6 LTS it should be possible to register a 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 the file 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 contain this:

$_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 table and field name to change the upload folder - good look :)



来源:https://stackoverflow.com/questions/27426426/set-upload-folder-when-using-fal-in-tca

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!