typo3typoscripttx-news

Typo3 News use first image of news as hero on page outside of the extension


I'm trying to get an image of a news in the detail view. I'd like to use it in another section of my layout. I would need it outside the news extension. So I tried:

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
        }

But unfortunately news_images is always empty, but the following returns me an url:

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
}

}

Why is the news_images empty but the url can be found?


Solution

  • For FilesProcessor, there is no uid-property. data as part of stdWrap has to be applied directly on references.

    So, this should do the job:

    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
          data = GP:tx_news_pi1|news
          // ^^^^
       }
       sorting = datetime
       sorting.direction = descending
       as = news_images
    }
    

    TS reference: https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/ContentObjects/Fluidtemplate/DataProcessing/FilesProcessor.html?#filesprocessor-stdwrap-on-references