带有来自页面资源的图像的流体菜单元素?

Fluid menu element with image from page resources?

我创建了一个新的流畅菜单元素,我需要它来为每个页面显示一个图像。图像存储在页面资源中。

当我调试模板时,每个菜单项都显示 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>

默认情况下,MenuProcessor 只是将 table 中的数据直接放入 Fluid 中的数组中。页面 table 中的 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
             }
           }
        }
    }
}