我创建了一个新的流畅菜单元素,我需要它来显示每个页面的图像。图像存储在页面资源中。
当我调试模板时,每个菜单项都显示data.media => 1
,但无法进一步扩展媒体。如何获取要在模板中渲染的图像?
TS:
ext_menu_image < lib.contentElement
ext_menu_image {
templateName = MenuImage
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
levels = 1
as = menuItems
expandAll = 1
titleField = nav_title // title
}
}
}
模板:
<f:for each="{menuItems}" as="page">
{f:uri.image(image:page.data.media.???)}
</f:for>
答案 0 :(得分:1)
默认情况下,MenuProcessor只是将来自表的数据直接放入Fluid中的数组中。页面表中的media
字段仅包含关系数。因此,您需要另一个数据处理器,以便将其转换为文件。应该这样做:
ext_menu_image < lib.contentElement
ext_menu_image {
templateName = MenuImage
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
levels = 1
as = menuItems
expandAll = 1
titleField = nav_title // title
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
}
}