Ask Your Question
4

How can I use sys_file_reference to retrieve images from a new field in tx_news?

asked 2021-04-19 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-10-16 02:00:00 +0000

lakamha gravatar image

To retrieve images from a new field in txnews using sysfile_reference, follow these steps:

  1. In the TYPO3 backend, go to the "List" module and select "News" from the dropdown menu.
  2. Click on the "Administration" tab and select "Table Configuration".
  3. In the "Fields" tab, add a new field of type "Inline" with the name of your choice, for example "news_image".
  4. Save the changes and reload the page.
  5. Now, when you create or edit a news item, you will see the new "news_image" field where you can upload an image.
  6. In your template or extension, use the following code to retrieve the image:
<f:for each="{newsItem.relatedFiles}" as="fileReference">
  <f:if condition="{fileReference.fieldname} == 'news_image'">
    <f:image image="{fileReference}" />
  </f:if>
</f:for>

This code loops through all the related files for the news item and checks if the fieldname matches "news_image". If it does, it displays the image using the f:image viewhelper.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-04-19 11:00:00 +0000

Seen: 12 times

Last updated: Oct 16 '21