FriendsOfTYPO3 / content-blocks

TYPO3 CMS Content Blocks - Content Types API
https://docs.typo3.org/p/friendsoftypo3/content-blocks/main/en-us/
GNU General Public License v2.0
61 stars 17 forks source link

Unable to Render Images from FlexForm Field within Collection in TYPO3 Frontend #292

Open tgrigoryan234 opened 21 hours ago

tgrigoryan234 commented 21 hours ago

I have an image field within a FlexForm field, but in the frontend, only the count of images is loaded, not the actual images. To address this, I need to write a custom Processor. This becomes more complex when the FlexForm field is part of a collection within a content element. Example Content Element config.yaml .... fields:

identifier: teasers
type: Collection
minitems: 1
table: tx_teasers
labelField: title
appearance:
  collapseAll: true
  levelLinksPosition: bottom
fields:
  - identifier: teaser
    type: FlexForm
    label: Teaser Settings

The FlexForm (teaser) inside this collection includes an image field. How can I retrieve and display the actual image in the frontend? There are currently no hooks or signals or options in the Data Decoration process that allow adding a field to Content Block data. In the past, this was possible using the offsetSet function. I don’t understand why it was removed.

nhovratov commented 20 hours ago

Which version are you on? TYPO3 v13 / v1 or TYPO3 v12 / 0.x?

nhovratov commented 20 hours ago

In v13 FlexForm relations should be resolved as well. Could you please show me your complete yaml snippet of the FlexForm field?

nhovratov commented 20 hours ago

Just tested it with this configuration and it works:

name: example/card-group
fields:
  - identifier: header
    useExistingField: true
  - identifier: settings
    type: FlexForm
    fields:
      - identifier: image
        type: File

Screenshot 2024-11-14 at 10-10-21 Home

nhovratov commented 20 hours ago

OK, your are RIGHT. When putting the FlexForm inside a Collection it does indeed not work.

nhovratov commented 20 hours ago

We will work on a bugfix in Core. Just one question: Why does the File field has to be inside FlexForm? Couldn't you just place it inside the Collection table?

There are currently no hooks or signals or options in the Data Decoration process that allow adding a field to Content Block data. In the past, this was possible using the offsetSet function. I don’t understand why it was removed.

There is! But it's not documented yet. See: https://github.com/FriendsOfTYPO3/content-blocks/issues/278

The offset function was removed in favor of this Event. This Event has more flexibility and it's easier to work with when having nested Collections like in your case.

tgrigoryan234 commented 20 hours ago

I wanted to create a FlexForm structure, for example, for a teaser with the same fields that could be used both as a standalone element and within a slider or accordion. To achieve this, I created a teaser FlexForm in tt_content and reused it across various content blocks.

nhovratov commented 18 hours ago

Created a forge issue: https://forge.typo3.org/issues/105597

tgrigoryan234 commented 15 hours ago

Thank you!