TYPO3在tca中设置上传文件夹

时间:2017-08-09 12:26:58

标签: typo3

'image' => array(
            'label' => 'LLL:EXT:fefiles/Resources/Private/Language/locallang_db.xlf:image',
            'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
                'image', array(
                'appearance' => array(
                    'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'
                ),
                'minitems' => 0,
                'maxitems' => 1,
                'foreign_match_fields' => array(
                    'fieldname' => 'image',
                    'tablenames' => 'tx_fechat_domain_model_smile',
                    'table_local' => 'sys_file_reference',
                ),
            ), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
            ),
        ),

我可以为此字段的文件准确设置上传文件夹吗? TYPO3版本7.6.18

1 个答案:

答案 0 :(得分:4)

通过Tca无法实现,但你可以使用钩子。

在localconf.php文件中

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauthgroup.php']['getDefaultUploadFolder']['my_ext'] = 'Vendor\\MYEXT\\Hooks\\BackendUserAuthentication->getDefaultUploadFolder';

in my_ext / Classes / Hooks / BackendUserAuthentication.php

namespace Vendor\MYEXT\Hooks;

class BackendUserAuthentication {
    public function getDefaultUploadFolder(Array $params, \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUserAuthentication) {
        //Define table name an field for which you want to change upload path
        if($params['table'] == 'tx_myext_domain_model_objectdetail' && ($params['field'] == 'mediafiles'||$params['field'] == 'image'))
        {
            $uploadFolder = new \TYPO3\CMS\Core\Resource\Folder($params['uploadFolder']->getStorage(),'/uploadfolder/','uploadfolder');

            return $uploadFolder;

        }
        return $params['uploadFolder'];
    }
}