Typo3 News 使用新闻的第一张图片作为扩展程序之外页面上的英雄

问题描述 投票:0回答:1

我正在尝试在详细视图中获取新闻图像。我想在布局的另一部分使用它。我需要它在新闻扩展之外。所以我尝试了:

7 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
        7 {
           if.isTrue.data = GP:tx_news_pi1|news
           references {
              table = tx_news_domain_model_news
              fieldName = fal_media
              uid.data = GP:tx_news_pi1|news
           }
           sorting = datetime
           sorting.direction = descending
           as = news_images
        }

但不幸的是 news_images 始终为空,但以下返回我一个网址:

lib.newsimage = FILES
lib.newsimage {
if.isTrue.data = GP:tx_news_pi1|news
references {
    table = tx_news_domain_model_news
    uid.data = GP:tx_news_pi1|news
    fieldName = fal_media
}
maxItems = 1
renderObj = IMG_RESOURCE
renderObj.file {
    import.data = file:current:publicUrl
}

}

为什么news_images是空的,但是可以找到url?

typo3 typoscript tx-news
1个回答
0
投票

对于 FilesProcessor,没有

uid
属性。 FilesProcessor 可以处理
files
collections
folders

所以,这应该可以完成工作:

7 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
7 {
   if.isTrue.data = GP:tx_news_pi1|news
   references {
      table = tx_news_domain_model_news
      fieldName = fal_media
      // vvvv
      files.data = GP:tx_news_pi1|news
      // ^^^^
   }
   sorting = datetime
   sorting.direction = descending
   as = news_images
}

TS 参考:https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Fluidtemplate/DataProcessing/FilesProcessor.html?#t3-data-processor-files-files

© www.soinside.com 2019 - 2024. All rights reserved.