TYPO3 网格元素:从 FlexForm FAL 字段渲染图像
TYPO3 gridelements: Render image from FlexForm FAL field
我正在尝试呈现多个相同类型的 FCE(gridelements 内容元素)。但是,不会渲染图像。
定义 FCE 的 flexform 有一个像这样的图像字段:
<image>
<TCEforms>
<config>
<type>inline</type>
<appearance type="array">
<createNewRelationLinkTitle>LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:createNewRelationLinkTitle</createNewRelationLinkTitle>
<headerThumbnail type="array">
<field>uid_local</field>
<height>45c</height>
<width>45</width>
</headerThumbnail>
</appearance>
<foreign_field>uid_foreign</foreign_field>
<foreign_label>uid_local</foreign_label>
<foreign_match_fields type="array">
<fieldname>image</fieldname>
</foreign_match_fields>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride type="array">
<config type="array">
<appearance type="array">
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai</elementBrowserAllowed>
<elementBrowserType>file</elementBrowserType>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_table>sys_file_reference</foreign_table>
<foreign_table_field>tablenames</foreign_table_field>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</image>
定义元素的 TypoScript 看起来是这样的:
tt_content.gridelements_pi1.20.10.setup {
3 < lib.gridelements.defaultGridSetup
3 {
stdWrap.cObject = COA
stdWrap.cObject {
10 = IMAGE
10 {
stdWrap.wrap = <div class="media-left">|</div>
file {
import.data = field:flexform_image
treatIdAsReference = 1
import.listNum = 0
}
}
}
}
}
问题
将元素放到页面上时,会显示图像。将多个元素放在同一页面上会导致每个元素呈现来自第一个 FCE 的图像放在页面上。一旦我编辑了一个 FCE(例如第二个放置的元素),根本就没有图像显示。
我该如何解决这个问题?
您需要确保每个 flexform 字段的文件名都是唯一的:
<foreign_match_fields type="array">
<fieldname>image</fieldname>
</foreign_match_fields>
最好使用真实的字段名。例如 flexform_image.
这是 flexform
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<ROOT type="array">
<type>array</type>
<el type="array">
<bgimage>
<TCEforms>
<label>Background Image</label>
<config>
<type>inline</type>
<foreign_field>uid_foreign</foreign_field>
<foreign_label>uid_local</foreign_label>
<foreign_match_fields type="array">
<fieldname>bgimage</fieldname>
</foreign_match_fields>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride type="array">
<config type="array">
<appearance type="array">
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai</elementBrowserAllowed>
<elementBrowserType>file</elementBrowserType>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_table>sys_file_reference</foreign_table>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</bgimage>
</el>
</ROOT>
</T3DataStructure>
我正在尝试呈现多个相同类型的 FCE(gridelements 内容元素)。但是,不会渲染图像。
定义 FCE 的 flexform 有一个像这样的图像字段:
<image>
<TCEforms>
<config>
<type>inline</type>
<appearance type="array">
<createNewRelationLinkTitle>LLL:EXT:myext/Resources/Private/Language/locallang_db.xlf:createNewRelationLinkTitle</createNewRelationLinkTitle>
<headerThumbnail type="array">
<field>uid_local</field>
<height>45c</height>
<width>45</width>
</headerThumbnail>
</appearance>
<foreign_field>uid_foreign</foreign_field>
<foreign_label>uid_local</foreign_label>
<foreign_match_fields type="array">
<fieldname>image</fieldname>
</foreign_match_fields>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride type="array">
<config type="array">
<appearance type="array">
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai</elementBrowserAllowed>
<elementBrowserType>file</elementBrowserType>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_table>sys_file_reference</foreign_table>
<foreign_table_field>tablenames</foreign_table_field>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</image>
定义元素的 TypoScript 看起来是这样的:
tt_content.gridelements_pi1.20.10.setup {
3 < lib.gridelements.defaultGridSetup
3 {
stdWrap.cObject = COA
stdWrap.cObject {
10 = IMAGE
10 {
stdWrap.wrap = <div class="media-left">|</div>
file {
import.data = field:flexform_image
treatIdAsReference = 1
import.listNum = 0
}
}
}
}
}
问题 将元素放到页面上时,会显示图像。将多个元素放在同一页面上会导致每个元素呈现来自第一个 FCE 的图像放在页面上。一旦我编辑了一个 FCE(例如第二个放置的元素),根本就没有图像显示。
我该如何解决这个问题?
您需要确保每个 flexform 字段的文件名都是唯一的:
<foreign_match_fields type="array">
<fieldname>image</fieldname>
</foreign_match_fields>
最好使用真实的字段名。例如 flexform_image.
这是 flexform
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<ROOT type="array">
<type>array</type>
<el type="array">
<bgimage>
<TCEforms>
<label>Background Image</label>
<config>
<type>inline</type>
<foreign_field>uid_foreign</foreign_field>
<foreign_label>uid_local</foreign_label>
<foreign_match_fields type="array">
<fieldname>bgimage</fieldname>
</foreign_match_fields>
<foreign_selector>uid_local</foreign_selector>
<foreign_selector_fieldTcaOverride type="array">
<config type="array">
<appearance type="array">
<elementBrowserAllowed>gif,jpg,jpeg,tif,tiff,bmp,pcx,tga,png,pdf,ai</elementBrowserAllowed>
<elementBrowserType>file</elementBrowserType>
</appearance>
</config>
</foreign_selector_fieldTcaOverride>
<foreign_sortby>sorting_foreign</foreign_sortby>
<foreign_table>sys_file_reference</foreign_table>
<maxitems>1</maxitems>
<minitems>0</minitems>
</config>
</TCEforms>
</bgimage>
</el>
</ROOT>
</T3DataStructure>