1

I would like to expand the content element "menu of subpages" with images from page resources.

In TYPO3 8.7 the following code did everything i needed:

<f:if condition="{menu}">
    <ul class="pagemenu-img">
        <f:for each="{menu}" as="page">
            <li>
                <a href="{page.link}"{f:if(condition: page.target, then: ' target="{page.target}"')} title="{page.title}">
                    <f:image src="fileadmin/{page.files.0.originalFile.identifier}" />
                    <span>{page.title}</span>
                </a>
            </li>
        </f:for>
    </ul>
</f:if>

With TYPO3 10.4 this isn't working anymore.
Is there another way? Preferably without using VHS.

Peter Kraume
  • 3,577
  • 2
  • 21
  • 39
Siriena
  • 57
  • 3
  • why don't you just create a new filed on your pages table where the user can add images? (extend the pages table) – Aristeidis Karavas Nov 26 '20 at 14:43
  • I think for this issue there is no need to create a new field. It worked well in the past. – Siriena Nov 26 '20 at 14:55
  • What means "this isn't working anymore"? Do you get an exception? What value has `page.files.0.originalFile.identifier`? – Julian Hofmann Nov 26 '20 at 20:05
  • 1
    I recieve the following error: Supplied file object type TYPO3\CMS\Core\Resource\Folder for fileadmin/ must be File or FileReference. It works when every subpage has an image uploaded. I included an if statement... now it works either way – Siriena Nov 27 '20 at 09:12
  • And `` doesn't throw an exception under TYPO3 v8.7? – Julian Hofmann Nov 27 '20 at 10:48
  • Hi there! Could you please consider marking the question as solved if you found a solution? thank you. – mtness Jan 20 '21 at 09:07

2 Answers2

1

It's still working.

I have tested your HTML-Template and the result is as expected: enter image description here

Your problems seem to be something other...

Julian Hofmann
  • 2,081
  • 1
  • 8
  • 16
0

Maybe there were some pages which didn't have any images with them...

You should therefore check if there is an image present: [and get rid of the hardcoded fileadmin/ link there by< just using {page.files.0.originalFile}]

<f:if condition="{menu}">
    <ul class="pagemenu-img">
        <f:for each="{menu}" as="page">
            <li>
                <a href="{page.link}"{f:if(condition: page.target, then: ' target="{page.target}"')} title="{page.title}">

                    <f:if condition="{page.files.0}">
                        <f:image image="{page.files.0.originalFile}" />
                    </f:if>

                    <span>{page.title}</span>
                </a>
            </li>
        </f:for>
    </ul>
</f:if>
mtness
  • 997
  • 9
  • 28