4

我有一个带有以下代码的flexform:

<image>
    <TCEforms>
        <label>LLL:EXT:my_slider/Resources/Private/Language/locallang.xlf:flexform.slider.main.slider.image</label>
        <config>
            <type>group</type>
            <internal_type>file</internal_type>
            <allowed>jpg, jpeg, gif, png</allowed>
            <show_thumbs>1</show_thumbs>
            <minitems>0</minitems>
            <maxitems>1</maxitems>
            <size>1</size>
        </config>
    </TCEforms>
</image>

到现在为止,这行得通。但是现在在 TYPO3 10 中我收到了这个错误:

表 tt_content 中字段“image”的 TCA internal_type 必须设置为“db”或“folder”。

我该如何解决这个问题?如何将我的 flexform 迁移到 FAL?我已经测试了一些解决方案,但它们以:

字段名称“pi_flexform”上的无效弹性表单数据结构在节容器“sliderConfiguration”中具有元素“图像”:不允许在弹性表单节中嵌套内联元素。

如果我写

<el>
    <settings.slider type="array">
    <title>LLL:EXT:my_slider/Resources/Private/Language/locallang.xlf:flexform.slider.main.slider</title>
    <type>array</type>
    <section>1</section>
    <el>
        <sliderConfiguration>
            <type>array</type>
            <title>LLL:EXT:my_slider/Resources/Private/Language/locallang.xlf:flexform.slider.main.slider.slide</title>
            <el>
                <media>
                    <!-- https://stackoverflow.com/questions/47554243/how-to-add-cropvariants-to-an-image-field-in-typo3-flexform -->
                    <TCEforms>
                        <label>
                            LLL:EXT:va_template/Resources/Private/Language/locallang.xlf:content_element.backgroundtext.settings.image
                        </label>
                        <config>
                            <type>inline</type>
                            <minitems>1</minitems>
                            <maxitems>1</maxitems>
                            <appearance type="array">
                                <enabledControls type="array">
                                    <delete>1</delete>
                                    <dragdrop>1</dragdrop>
                                    <new>0</new>
                                    <hide>1</hide>
                                    <info>1</info>
                                </enabledControls>
                                <fileUploadAllowed>1</fileUploadAllowed>
                                <headerThumbnail type="array">
                                    <field>uid_local</field>
                                    <height>100c</height>
                                    <width>100</width>
                                </headerThumbnail>
                                <useSortable>1</useSortable>
                            </appearance>
                            <foreign_field>uid_foreign</foreign_field>
                            <foreign_label>uid_local</foreign_label>
                            <foreign_match_fields type="array">
                                <fieldname>media</fieldname>
                            </foreign_match_fields>
                            <foreign_selector>uid_local</foreign_selector>
                            <foreign_sortby>sorting_foreign</foreign_sortby>
                            <foreign_table>sys_file_reference</foreign_table>
                            <foreign_table_field>tablenames</foreign_table_field>
                        </config>
                    </TCEforms>
                </media>

然后我得到这个错误

字段名称“pi_flexform”与节容器“sliderConfiguration”中元素“media”的无效弹性表单数据结构:不允许在弹性表单节中嵌套内联元素。

4

6 回答 6

6

我在这里写了完整的 flexform 配置,它将使用typo3 10 运行。

<image>
                <TCEforms>
                    <label>LLL:EXT:ns_theme_healthy/Resources/Private/Language/locallang_flex.xlf:general.image</label>
                    <config>
                        <type>inline</type>
                        <maxitems>1</maxitems>
                        <foreign_table>sys_file_reference</foreign_table>
                        <foreign_table_field>tablenames</foreign_table_field>
                        <foreign_label>uid_local</foreign_label>
                        <foreign_sortby>sorting_foreign</foreign_sortby>
                        <foreign_field>uid_foreign</foreign_field>
                        <foreign_selector>uid_local</foreign_selector>
                        <foreign_selector_fieldTcaOverride>
                            <config>
                                <appearance>
                                    <elementBrowserType>file</elementBrowserType>
                                    <elementBrowserAllowed>gif,jpg,jpeg,png,svg</elementBrowserAllowed>
                                </appearance>
                            </config>
                        </foreign_selector_fieldTcaOverride>
                        <foreign_types type="array">
                            <numIndex index="0">
                                <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                            </numIndex>
                            <numIndex index="2">
                                <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                            </numIndex>
                        </foreign_types>
                        <foreign_match_fields>
                            <fieldname>image</fieldname> <!-- CAUTION!! Replace "fal" with the variable name of this field! -->
                        </foreign_match_fields>
                        <appearance type="array">
                            <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                            <headerThumbnail>
                                <field>uid_local</field>
                                <height>64</height>
                                <width>64</width>
                            </headerThumbnail>
                            <enabledControls>
                                <info>1</info>
                                <new>0</new>
                                <dragdrop>0</dragdrop>
                                <sort>1</sort>
                                <hide>0</hide>
                                <delete>1</delete>
                                <localize>1</localize>
                            </enabledControls>
                            <createNewRelationLinkTitle>LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:images.addFileReference</createNewRelationLinkTitle>
                        </appearance>
                        <behaviour>
                            <localizationMode>select</localizationMode>
                            <localizeChildrenAtParentLocalization>1</localizeChildrenAtParentLocalization>
                        </behaviour>
                        <overrideChildTca>
                            <columns type="array">
                                <uid_local type="array">
                                    <config type="array">
                                        <appearance type="array">
                                            <elementBrowserType>file</elementBrowserType>
                                            <elementBrowserAllowed>jpg,png,svg,jpeg,gif</elementBrowserAllowed>
                                        </appearance>
                                    </config>
                                </uid_local>
                            </columns>
                            <types type="array">
                                <numIndex index="2">
                                    <showitem>--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette,--palette--;;filePalette</showitem>
                                </numIndex>
                            </types>
                        </overrideChildTca>
                    </config>
                </TCEforms>
            </image>

我已经测试了这将是我全新的typo3 10 项目。

我希望它对你有帮助。谢谢!

于 2020-06-09T11:17:50.213 回答
1

max.haredoom 的解决方案有效:) 干得好,伙计。奇怪的是它只在没有“设置......”的情况下工作

如果您需要将其用于自定义内容元素,则可以将以下内容添加到您的处理器文件中:

    if (isset($processedData['content']['images']) &&
        (int) $processedData['content']['images'] > 0) {
        $fileRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\FileRepository::class);
        $fileObjects = $fileRepository->findByRelation('tt_content', 'image', $processedData['data']['uid']);
        // now loop over objects and get sys_file uids via $fileObject->getOriginalFile()->getUid();
    }
于 2020-05-08T16:34:32.230 回答
0

我找到了这个。所选图像保存在 tt_content 中。但保存后它不会出现在后端表单中。

<options.image1>
    <TCEforms>
        <label>Bild</label>
        <config>
            <type>inline</type>
            <type>group</type>
            <internal_type>db</internal_type>
            <maxitems>1</maxitems>
            <foreign_table>sys_file_reference</foreign_table>
            <foreign_field>uid_foreign</foreign_field>
            <foreign_sortby>sorting_foreign</foreign_sortby>
            <foreign_table_field>tablenames</foreign_table_field>
            <foreign_match_fields>
                <fieldname>--feldname--</fieldname>
            </foreign_match_fields>
            <foreign_label>uid_local</foreign_label>
            <foreign_selector>uid_local</foreign_selector>
            <foreign_selector_fieldTcaOverride>
                <config>
                    <appearance>
                        <elementBrowserType>file</elementBrowserType>
                        <elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai</elementBrowserAllowed>
                    </appearance>
                </config>
            </foreign_selector_fieldTcaOverride>
            <appearance>
                <elementBrowserType>file</elementBrowserType>
                <elementBrowserAllowed>jpg,jpeg,png,gif</elementBrowserAllowed>
            </appearance>
            <allowed>sys_file</allowed>
            <size>5</size>
            <minitems>0</minitems>
            <maxitems>5</maxitems>
            <show_thumbs>1</show_thumbs>
        </config>
    </TCEforms>
</options.image1>
于 2020-04-27T08:50:02.107 回答
0

我找到了一个解决方案:请参见此处:如何在 TYPO3 10 中以自定义 extbase 扩展的 flexform 创建文件上传字段?

或者为了您的方便:

<T3DataStructure>
<sheets>
    <sDEF>
        <ROOT>
            <TCEforms>
                <sheetTitle>Example 1</sheetTitle>
            </TCEforms>
            <type>array</type>
            <el>
                <!-- example of a working fal image -->
                <images>
                    <label>FAL-Images</label>
                    <config>
                        <type>inline</type>
                        <foreign_table>sys_file_reference</foreign_table>
                        <foreign_field>uid_foreign</foreign_field>
                        <foreign_sortby>sorting_foreign</foreign_sortby>
                        <foreign_table_field>tablenames</foreign_table_field>
                        <foreign_match_fields>
                            <fieldname>image</fieldname>
                        </foreign_match_fields>
                        <foreign_label>uid_local</foreign_label>
                        <foreign_selector>uid_local</foreign_selector>
                        <overrideChildTca>
                            <columns>
                                <uid_local>
                                    <config>
                                        <appearance>
                                            <elementBrowserType>file</elementBrowserType>
                                            <elementBrowserAllowed></elementBrowserAllowed>
                                        </appearance>
                                    </config>
                                </uid_local>
                            </columns>
                        </overrideChildTca>
                        <filter>
                            <userFunc>TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter->filterInlineChildren</userFunc>
                            <parameters>
                                <allowedFileExtensions></allowedFileExtensions>
                                <disallowedFileExtensions></disallowedFileExtensions>
                            </parameters>
                        </filter>
                        <appearance>
                            <useSortable>1</useSortable>
                            <headerThumbnail>
                                <field>uid_local</field>
                                <width>45</width>
                                <height>45c</height>
                            </headerThumbnail>
                            <enabledControls>
                                <info>1</info>
                                <new>0</new>
                                <dragdrop>1</dragdrop>
                                <sort>0</sort>
                                <hide>1</hide>
                                <delete>1</delete>
                            </enabledControls>
                        </appearance>
                    </config>
                </images>
                <!-- end -->
            </el>
        </ROOT>
    </sDEF>
</sheets>

于 2020-05-08T10:11:19.510 回答
0

像在标准内容元素中那样做呢?

在 TYPO3 后端转到模块Configuration
并选择$GLOBALS['TCA'] (Table configuration array)
然后找到路径tt_content.columns.media.config

选择这些字段和值并将其作为 XML 插入到您的定义中

于 2020-04-23T10:01:21.533 回答
0

如果您想编辑由 DCE 扩展创建的字段,我在将 Typo3 9.x 更新到 Typo3 10.x 后遇到了类似的错误。

我过去的 dce 元素配置,这给了我错误是:

<config>
    <type>group</type>
    <internal_type>file</internal_type>
    <allowed>jpg,jpeg,png,gif</allowed>
    <size>1</size>
    <minitems>0</minitems>
    <maxitems>1</maxitems>
    <show_thumbs>1</show_thumbs>
</config>

将 <internal_type> 从文件更改为文件后,错误消失了,一切都很好了。后端还告诉我选项“db”在某些情况下也可能会起作用。

<config>
    <type>group</type>
    <internal_type>folder</internal_type>
    <allowed>jpg,jpeg,png,gif</allowed>
    <size>1</size>
    <minitems>0</minitems>
    <maxitems>1</maxitems>
    <show_thumbs>1</show_thumbs>
</config>
于 2021-01-07T13:53:08.750 回答