【问题标题】:Add A repeator field using flexform in custom extension在自定义扩展中使用 flexform 添加转发器字段
【发布时间】:2022-09-22 21:10:32
【问题描述】:

我想要一个包含两个子字段顶部图像和底部图像的公共字段“图像”。公共字段“Images”应该是可重复字段,意味着可以多次添加。我附上下面的演示。有人可以帮忙吗?

这是我的 flexform 代码。有图像顶部图像和底部图像两个字段。我想让这两个成为我的功能。

<T3DataStructure>
  <sheets>
    <sDEF>
      <ROOT>
        <TCEforms>
          <sheetTitle>Settings</sheetTitle>
        </TCEforms>
        <type>array</type>
        <el>
          <settings.gallerytype>
            <TCEforms>
              <label>Gallery Type</label>
              <onChange>reload</onChange>
              <config>
                <type>select</type>
                <renderType>selectSingle</renderType>
                <items type=\"array\">
                  <numIndex index=\"0\" type=\"array\">
                    <numIndex index=\"0\">-Select-</numIndex>
                  </numIndex>
                  <numIndex index=\"1\" type=\"array\">
                    <numIndex index=\"0\">Simple Gallery</numIndex>
                    <numIndex index=\"1\">0</numIndex>
                  </numIndex>
                  <numIndex index=\"2\" type=\"array\">
                    <numIndex index=\"0\">Parallax</numIndex>
                    <numIndex index=\"1\">1</numIndex>
                  </numIndex>
                  <numIndex index=\"3\" type=\"array\">
                    <numIndex index=\"0\">Grid Gallery</numIndex>
                    <numIndex index=\"1\">2</numIndex>
                  </numIndex>
                  <numIndex index=\"4\" type=\"array\">
                    <numIndex index=\"0\">Sliders</numIndex>
                    <numIndex index=\"1\">3</numIndex>
                  </numIndex>
                  <numIndex index=\"5\" type=\"array\">
                    <numIndex index=\"0\">Portfolio</numIndex>
                    <numIndex index=\"1\">4</numIndex>
                  </numIndex>
                  <numIndex index=\"6\" type=\"array\">
                    <numIndex index=\"0\">Filter Gallery</numIndex>
                    <numIndex index=\"1\">5</numIndex>
                  </numIndex>
                </items>
                <minitems>1</minitems>
                <maxitems>1</maxitems>
                <size>1</size>
              </config>
            </TCEforms>
          </settings.gallerytype>
          <settings.gridsubstyle>
            <TCEforms>
              <label>Select the style for gallery type</label>
              <onChange>reload</onChange>
              <displayCond>FIELD:settings.gallerytype:=:2</displayCond>
              <config>
                <type>select</type>
                <renderType>selectSingle</renderType>
                <items type=\"array\">
                  <numIndex index=\"0\" type=\"array\">
                  </numIndex>
                  <numIndex index=\"1\" type=\"array\">
                    <numIndex index=\"0\">One column Image display</numIndex>
                    <numIndex index=\"1\">6</numIndex>
                  </numIndex>
                  <numIndex index=\"2\" type=\"array\">
                    <numIndex index=\"0\">Two column Image display</numIndex>
                    <numIndex index=\"1\">7</numIndex>
                  </numIndex>
                  <numIndex index=\"3\" type=\"array\">
                    <numIndex index=\"0\">Three column Image display</numIndex>
                    <numIndex index=\"1\">8</numIndex>
                  </numIndex>
                  <numIndex index=\"4\" type=\"array\">
                    <numIndex index=\"0\">Four column Image display</numIndex>
                    <numIndex index=\"1\">9</numIndex>
                  </numIndex>
                </items>
                <minitems>1</minitems>
                <maxitems>1</maxitems>
                <size>1</size>
              </config>
            </TCEforms>
          </settings.gridsubstyle>

          <settings.slidersubstyle>
            <TCEforms>
              <label>Select the style for gallery type</label>
              <onChange>reload</onChange>
              <displayCond>FIELD:settings.gallerytype:=:3</displayCond>
              <config>
                <type>select</type>
                <renderType>selectSingle</renderType>
                <items type=\"array\">
                  <numIndex index=\"0\" type=\"array\">
                    <numIndex index=\"0\">-Select-</numIndex>
                  </numIndex>
                  <numIndex index=\"1\" type=\"array\">
                    <numIndex index=\"0\">Banner Slider</numIndex>
                    <numIndex index=\"1\">10</numIndex>
                  </numIndex>
                  <numIndex index=\"2\" type=\"array\">
                    <numIndex index=\"0\">Treadmill</numIndex>
                    <numIndex index=\"1\">11</numIndex>
                  </numIndex>
                </items>
                <minitems>1</minitems>
                <maxitems>1</maxitems>
                <size>1</size>
              </config>
            </TCEforms>
          </settings.slidersubstyle>


          <settings.filtersubstyle>
            <TCEforms>
              <label>Select the style for gallery type</label>
              <onChange>reload</onChange>
              <displayCond>FIELD:settings.gallerytype:=:5</displayCond>
              <config>
                <type>select</type>
                <renderType>selectSingle</renderType>
                <items type=\"array\">
                  <numIndex index=\"0\" type=\"array\">
                    <numIndex index=\"0\">-Select-</numIndex>
                  </numIndex>
                  <numIndex index=\"1\" type=\"array\">
                    <numIndex index=\"0\">Gallery with Filter</numIndex>
                    <numIndex index=\"1\">12</numIndex>
                  </numIndex>
                  <numIndex index=\"2\" type=\"array\">
                    <numIndex index=\"0\">Standard Gallery with Filter</numIndex>
                    <numIndex index=\"1\">13</numIndex>
                  </numIndex>
                </items>
                <minitems>1</minitems>
                <maxitems>1</maxitems>
                <size>1</size>
              </config>
            </TCEforms>
          </settings.filtersubstyle>

          <settings.gallerytitle>
            <TCEforms>
              <label>Gallery Title</label>
              <config>
                <type>input</type>
                <size>200</size>
              </config>
            </TCEforms>
          </settings.gallerytitle>
          <galleryimage>
            <TCEforms>
              <label>Images</label>
              <onChange>reload</onChange>
              <displayCond>
                <OR>
                  <numIndex index=\"1\">FIELD:settings.gallerytype:=:0</numIndex>
                  <numIndex index=\"2\">FIELD:settings.gallerytype:=:1</numIndex>
                  <numIndex index=\"3\">FIELD:settings.gallerytype:=:4</numIndex>
                  <numIndex index=\"4\">FIELD:settings.gridsubstyle:=:6</numIndex>
                  <numIndex index=\"5\">FIELD:settings.gridsubstyle:=:7</numIndex>
                  <numIndex index=\"6\">FIELD:settings.gridsubstyle:=:8</numIndex>
                  <numIndex index=\"7\">FIELD:settings.gridsubstyle:=:9</numIndex>
                  <numIndex index=\"8\">FIELD:settings.slidersubstyle:=:10</numIndex>
                  <numIndex index=\"9\">FIELD:settings.filtersubstyle:=:12</numIndex>
                  <numIndex index=\"10\">FIELD:settings.filtersubstyle:=:13</numIndex>
                </OR>
              </displayCond>
              <config>
                <type>inline</type>
                <maxitems>2000</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>jpg,jpeg,png</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>Galleryimage</fieldname>
                  <!-- CAUTION!! Replace \"fal\" with the variable name of this field! -->
                </foreign_match_fields>
                <appearance type=\"array\">
                  <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                  <useSortable>1</useSortable>
                  <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>1</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,jpeg,png</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>
          </galleryimage>
          <topimage>
            <TCEforms>
              <label>Top Image</label>
              <onChange>reload</onChange>
              <displayCond>
                <OR>
                  <numIndex index=\"1\">FIELD:settings.slidersubstyle:=:11</numIndex>
                </OR>
              </displayCond>
              <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>jpg,jpeg,png</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>Topimage</fieldname>
                  <!-- CAUTION!! Replace \"fal\" with the variable name of this field! -->
                </foreign_match_fields>
                <appearance type=\"array\">
                  <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                  <useSortable>1</useSortable>
                  <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>1</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,jpeg,png</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>
          </topimage>

          <bottomimage>
            <TCEforms>
              <label>Bottom Image</label>
              <onChange>reload</onChange>
              <displayCond>
                <OR>
                  <numIndex index=\"1\">FIELD:settings.slidersubstyle:=:11</numIndex>
                </OR>
              </displayCond>
              <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>jpg,jpeg,png</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>Bottomimage</fieldname>
                  <!-- CAUTION!! Replace \"fal\" with the variable name of this field! -->
                </foreign_match_fields>
                <appearance type=\"array\">
                  <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                  <useSortable>1</useSortable>
                  <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>1</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,jpeg,png</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>
          </bottomimage>
          <settings.treadmill>
            <TCEforms>
              <label>Add media</label>
              <onChange>reload</onChange>
              <displayCond>
                <OR>
                  <numIndex index=\"1\">FIELD:settings.slidersubstyle:=:11</numIndex>
                </OR>
              </displayCond>
              <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>jpg,jpeg,png</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>Bottomimage</fieldname>
                  <!-- CAUTION!! Replace \"fal\" with the variable name of this field! -->
                </foreign_match_fields>
                <appearance type=\"array\">
                  <newRecordLinkAddTitle>1</newRecordLinkAddTitle>
                  <useSortable>1</useSortable>
                  <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>1</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,jpeg,png</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>
          </settings.treadmill>
          <settings.enablefilter>
            <TCEforms>
              <label>Enable Filter</label>
              <config>
                <type>check</type>
                <maxitems>2</maxitems>
              </config>
            </TCEforms>
          </settings.enablefilter>
        </el>
      </ROOT>
    </sDEF>
  </sheets>
</T3DataStructure>

.

    标签: typo3 typo3-extensions


    【解决方案1】:

    创建一个额外的记录类型“图像”(包括 TCA、SQL 表等),具有两个必填字段“顶部图像”和“底部图像”。然后在父记录中配置一个IRRE/inline-type 字段。

    【讨论】:

    • 你能给出一个示例代码吗?因为我是typo3的新手。
    • 我在我的问题中添加了 flexform 代码......你能检查一下吗?请帮忙。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 2016-05-06
    • 2021-06-07
    • 1970-01-01
    相关资源
    最近更新 更多