I am using the basetemplate9
extension provided by Sebastian Klein (https://github.com/sebkln/basetemplate9).
I customize it using other HTML templates (from Bootstrap) and of course adapting the backendend layout.
Everything is working fine, content from the backend layout is mapped to the HTML templates.
BUT, I am not happy with the current solution with respect to uploaded images.
Currently, for images , I just upload them into the /fileadmin/user_uploads
directory and I map them using
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: 'x'}"/>
where x is number of the accordant colPos defined in the backend layout.
The image is then rendered using TYPO3 styles. But I want to control the images properties. The image shall always be rendered in the same way irrespectively what the editor edits.
Therefore, in the HTML template I want to define image properties like width, height and I want to use the f:image view helper (https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/Image.html).
My question now is: How I can map the uploaded image (using specific colPos in the backend layout) into the src of the image view helper?
<f:image src="{THIS_VALUE_SHOULD_POINT_TO_THE_IMAGE_UPLOADED_VIA_COLPOS_OF_ASSOCIATED_BACKENDLAYOUT}}" width="400" height="200" alt="My Image" />
If I specify hardcoded the uid
of table sys_file (in my case it is 2), then I can "find" the respective image using a FileProcessor (see code below) but how can I nest this FileProcessor in a DatabaseQueryProcessor so that I find the associated colPos from my backend layout. I am missing this piece of logic.
// In the FLUIDTEMPLATE TypoScript
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
references.fieldName = image
references.table = tt_content
files = 2 //hardcoded uid of table sys_file
folders = 1:fileadmin/user_upload/
folders.recursive = 1
sorting = description
sorting.direction = descending
as = myfiles
}
<f:for each="{myfiles}" as="file">
<li><a href="{file.identifier}">{file.name}</a></li>
<f:image class="img-fluid rounded mb-4 mb-lg-0"
src="/fileadmin/{file.identifier}" width="900c" height="400c"
alt="Christian Alt Default Titel" title="Christian Default Titel"
/>
</f:for>
Update on 22/07/2019
I was inspired by the approach described in https://www.rutschmann.biz/en/blog/post/dataprocessor-gridelements-und-fal-bilder-im-fluidtemplate-4-beginners/.
Basically the author selects the image uploaded by a specific colPos using tt_content and passes the record to a FilesProcessor.
I want to follow the same approach below but it is based on the Typo3 7 LTS, I am using version 9.5.8 and the typoscript code is not working in my version, especially the following code snippet:
where.wrap = tx_gridelements_columns = 101 AND tx_gridelements_container=|
Here the approach from the author of the link above:
imagetextbox < lib.gridelements.defaultGridSetup
imagetextbox {
cObject = FLUIDTEMPLATE
cObject {
file = EXT:customtheme/Resources/Private/Templates/GridElements/Imagetextbox.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
10 {
table = tt_content
where.data = field:uid
where.wrap = tx_gridelements_columns = 101 AND tx_gridelements_container=|
orderBy = sorting
as = content
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
references.table = tt_content
as = image
}
}
}
}
}
outerWrap = |
}
gridelements
as it belongs to your code. the question appears: do you actively usegridelements
at all?gridelements
does a lot of special handling regardingcolPos
so it makes a different if it has to be considered. – Bernd Wilke πφ