带有页面资源图像的流畅菜单元素?

时间:2019-10-15 11:15:11

标签: typo3 typoscript fluid typo3-9.x

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

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

1 个答案:

答案 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
             }
           }
        }
    }
}