Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Add Example for FilesProcessor with a FlexForm file #786

Merged
merged 4 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,36 @@ for file resources:
The :php:`FilesProcessor` can slide up the rootline to collect images for Fluid
templates. One usual feature is to take images attached to pages and use them on
the page tree as header images in the frontend.

.. _FilesProcessor-FlexForm:

Example 3: files from a FlexForm
================================

If the files are stored in a FlexForm, the entry in the table
:sql:`sys_file_reference` uses the name of the main table, for example
:sql:`tt_content` and the FlexForm key as :sql:`fieldname`.

Therefore you can do the following:

.. literalinclude:: _FilesProcessorFlexForm.typoscript
:language: typoscript
:caption: EXT:site_package/Configuration/TypoScript/setup.typoscript

This assumes that the image was stored in a FlexForm in the table
:sql:`tt_content` like this:

.. literalinclude:: _FlexFormWithImage.xml
:language: xml
:caption: EXT:site_package/Configuration/FlexForm/MyFlexForm.xml

Three images in the same content element (uid 15) having the FlexForm above
would look like this in the the database table :sql:`sys_file_reference`:

===== ===== =========== ============= ============ ================== =====
uid pid uid_local uid_foreign tablenames fieldnames ...
===== ===== =========== ============= ============ ================== =====
42 120 12 15 tt_content settings.myImage ...
43 120 25 15 tt_content settings.myImage ...
44 120 128 15 tt_content settings.myImage ...
===== ===== =========== ============= ============ ================== =====
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
page.10.dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.table = tt_content
references.field = settings.myImage
as = myImageFromFlexForm
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
<sheets>
<main>
<ROOT type="array">
<TCEforms><sheetTitle>Something</sheetTitle></TCEforms>
<type>array</type>
<el type="array">
<settings.myImage>
<TCEforms>
<label>My Images</label>
<config>
<type>file</type>
<maxitems>6</maxitems>
<allowed>common-image-types</allowed>
</config>
</TCEforms>
</settings.myImage>
</el>
</ROOT>
</main>
</sheets>
</T3DataStructure>
Loading