typo3fedext

Enable sliding for page resources with Fluid Powered TYPO3 vhs


Hi everybody out there,

I have configured my page template so that I can create FAL relations. I'm able to read the data of the current page and spit out the image.

But what I really want is that I can slide up - if there is no FAL relation at the current page then I would like to look in the parent page for an image - and the parents parent page if the parent itself have no FAL relation (and so on - until I'm at the root page).

After reading the documentation something like this is possible with content, but I can not find any hints how to do this with page resources.

Hopefully someone can help

Markus


Solution

  • You can use the vhs viewhelper v:page.resource in combination with the slide argument, wich is supported from vhs version 2.3.3.

    {namespace v=FluidTYPO3\Vhs\ViewHelpers}
    
    <v:page.resources.fal table="pages" field="media" uid="{page.uid}" as="images" slide="-1" >
      <f:for each="{images}" as="image">
        <f:image src="{image.url}" alt="{image.alternative} {image.name}" title="{image.title}" />
      </f:for>
    </v:page.resources.fal>
    

    Inline-syntax-example for the first element

    <v:resource.image identifier="{v:page.resources.fal(field: 'media', uid: '{page.uid}' slide:'-1') -> v:iterator.extract(key: 'id') -> v:iterator.first()}" treatIdAsReference="1" maxWidth="1500"/>