In an extbase extension, I have a FileReference Object. It was created with extension_builder originally. From The Model:
/**
* apprenticeshipDocument
*
@var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $apprenticeshipDocument = NULL;
etc.
In the frontend, <f:debug>{institution.apprenticeshipDocument}</f:debug>
gives me this:
First Thing: originalResource
is missing.
Second: When calling {institution.apprenticeshipDocument.uidLocal} directly, the value is NULL! Although it's said to be 450 above.
Third: Let's say we could get uidLocal, which corresponds to the uid in sys_file.
The googlable solution:
<f:link.page pageUid="{f:uri.image(src:450)}" target="_blank">Text</f:link.page>
doesn't point to the PDF file itself, but to a rendered GIF of the PDF.
All I want to do is output the path to the file (sys_file.identifier
) in a link... there must be a way, mustn't it?
EDIT: Solution provided by Jost:
<f:if condition="{institution.apprenticeshipDocument}">
<li>
<f:link.page pageUid="{institution.apprenticeshipDocument.originalResource.publicUrl}" target="_blank">Text</f:link.page>
</li>
</f:if>
originalResource
is lazy-loaded, so it is correct to beNULL
. Just access it. I believe you can also access it and then do the f:debug to see all its fields. One of them will beoriginalFile
, which is also lazy-loaded. – JostuidLocal
not being accessible is probably that there is no getter for it, so fluid can't read it. To link the file, I usually use thev:link.typolink
ViewHelper from EXT:vhs, which you can use like this:<v:link.typolink configuration="{parameter: 'file:{variableContainingUid}'}>Linktext</v:link.typoscript>
. Alternatively, you could use{institution.apprenticeshipDocument.originalResource.publicUrl}
to get the URL (not sure about the exact name). – JostpublicUrl
-property of the file (or reference) instead - there is a getter for it in the fileInterface, so both file and file reference have that property. Also, there are more properties available, that you can't see in the debug output, mostly metadata - they are accessed using a magic getter. – Jost