I have such page structure (Typo3 v10):
Page 1
- Page 1.1
- Page 1.2
- - Page 1.2.1
...
Page 2
- Page 2.1
- Page 2.2
...
I need to show an image (from page resources) with sliding feature. So I use this code:
lib.banner = FILES
lib.banner {
references {
table = pages
data = levelmedia: -1, slide
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
wrap = <div class="banner">|</div>
}
}
In HTML template I use it as follow:
<f:cObject typoscriptObjectPath="lib.banner" />
Everything works nice. I see the image from CURRENT page resources or from the CURRENT page's parents resources.
Now If I need to show the image from other page with special id I use the following code
lib.banner = FILES
lib.banner {
references {
table = pages
uid.data = field:PageIdParam
fieldName = media
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
wrap = <div class="banner">|</div>
}
}
In HTML:
<f:cObject typoscriptObjectPath="lib.banner" data="{ PageIdParam: 123 } />
But what if I need to add sliding feature?
I try to use the following code:
lib.banner = FILES
lib.banner {
references {
table = pages
data = levelmedia: -1, slide
uid.data = field:PageIdParam
fieldName = media
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
wrap = <div class="banner">|</div>
}
}
Unfortunately it stop working.. what I do wrong?
I also tried to play around with file.import.data = levelmedia:-1, slide, but did not help
UPDATE:
More detailed info with explanation why I need this:
I created a custom content element (according to https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html)
The element outputs the list of images. Images are taken from the pages.
Typoscript for the content element:
tt_content {
images_from_pages =< lib.contentElement
images_from_pages {
templateName = ImagesFromPages
dataProcessing {
30 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
30 {
special = list
special.value.field = pages
maxItems = 100
as = contentElementPages
titleField = nav_title // title
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
}
}
}
To output the images I used the fluid template:
<html data-namespace-typo3-fluid="true" xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers">
<f:if condition="{contentElementPages}">
<f:for each="{contentElementPages}" as="page">
<h2>{page.title}</h2>
<f:if condition="{page.files.0} ">
<f:then>
<f:render partial="ImagesFromPages/Image" arguments="{file: page.files.0}" />
</f:then>
<f:else>
<f:cObject
typoscriptObjectPath="lib.banner"
data="{
parentPageId: page.data.pid,
width: '300c',
height: '300c'
}"
/>
</f:else>
</f:if>
</f:for>
</f:if>
</html>
So as a result I have a list of [page1 title / img1, page2 title / img2 ...]
In case if the page in the cycle has no image, I use page.data.pid to reference the "parent page"
The problem I could not solve yet: if the parent page has no image as well, I need to output the image of parent of parent recursively (sliding).
I know, I could use "default image or image from root page", but first I would like to try to get the image from "parent of parent page"
