I have question about file download with Extbase and FAL. I can render image with
<f:image src="{file.uid}" alt="" width='100' height="100" treatIdAsReference="1"/>
I can get image, but I also have PDF file for download, and I can't use this ViewHelper. Is there any other ViewHelper for file downloads? If i dump that file i get this:
file => TYPO3\CMS\Extbase\Domain\Model\FileReferenceprototypepersistent entity (uid=1342, pid=310)
originalResource => NULL
uid => 1342 (integer)
_localizedUid => 1342 (integer)modified
_languageUid => 0 (integer)modified
pid => 310 (integer)
originalResource is null for file, and for image, image is printed with that ViewHelper. And I can't get file...
Any help is welcome...
You can use the publicURL property of the originalResource to create a file link.
Sample Fluid to generate a list of files referenced in your domain model property
<ul class="download-list">
<f:for each="{myObject.myFALproperty}" as="file" >
<li><a href="{file.originalResource.publicUrl}">{file.originalResource.title}</a></li>
</f:for>
</ul>
Just use the {myObject.myFALproperty} to see what you can access.
If you need more properties here are the basics of the Original and the reference in case you want to use the override located in the FlexForm
Original Attributes
filename :{myObject.myFALproperty.originalResource.originalFile.name}
title:{myObject.myFALproperty.originalResource.originalFile.title}
description:{myObject.myFALproperty.originalResource.originalFile.description}
alt:{myObject.myFALproperty.originalResource.originalFile.alternative}
uid:{myObject.myFALproperty.originalResource.originalFile.uid}
path:{myObject.myFALproperty.originalResource.publicUrl}
Reference Attributes
title: {myObject.myFALproperty.originalResource.title}
description {myObject.myFALproperty.originalResource.description}
Hope that helps.
Just for reference this is what the according TCA looks like, but you obviously already know that (note this sample has a maxitems setting of 10:
'myFALproperty' => array(
'exclude' => 0,
'label' => 'LLL:EXT:xy_sample/Resources/Private/Language/locallang_db.xlf:tx_xysample_domain_model_myobject.myFALproperty',
'config' =>
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'myFALproperty',
array('maxitems' => 10)
),
),