简体   繁体   English

如何以编程方式在TYPO3中的自定义扩展中添加文件收集记录

[英]How to add file collection record programatically in custom extension in TYPO3

I want to add the file collection record programatically in a custom record I have created in the backend. 我想以编程方式在后端创建的自定义记录中添加文件收集记录。

I can add separate files right now after I created a custom model which had the file property, but I cannot control which folder it goes to right now, so I want to instead make a file collection type of record inside my custom model so I can have more control over which folder the file gets uploaded. 创建具有文件属性的自定义模型后,我可以立即添加单独的文件,但是我无法控制它现在转到哪个文件夹,因此我想改为在自定义模型中创建记录的文件集合类型,以便可以控制文件上传到哪个文件夹。

Any help is appreciated. 任何帮助表示赞赏。 Thank you 谢谢

If someone else stumbles upon this, here is how I did it. 如果有人偶然发现了这,我就是这样做的。

'files'            => [
        'exclude' => 0,
        'label'   => 'Files',
        'config'  => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( 'files',
            [
                'appearance'           => [
                    'createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference',
                ],
                // custom configuration for displaying fields in the overlay/reference table
                // to use the imageoverlayPalette instead of the basicoverlayPalette
                'foreign_match_fields' => [
                    'fieldname'   => 'files',
                    'tablenames'  => 'tx_table_name',
                    'table_local' => 'sys_file',
                ],
            ] ),
    ],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM