Reputation: 5122
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>
Upvotes: 4
Views: 5015
Reputation: 5840
Files and file references behave a bit different in fluid than usual:
originalResource
(Extbase file reference) and originalFile
(Core file reference) values are NULL
before the first access to them. But you can just access them as usual.uidLocal
of an extbase file reference can't be accessed because there is no getter for it (as of TYPO3 6.2.12 and 7.2).To get the url of a file, use its publicUrl
attribute, or use the ViewHelper v:link.typolink
from EXT:vhs, like this:
<v:link.typolink configuration="{parameter: 'file:{uid}'}>
Linktext
</v:link.typolink>
uid
is the id of the file in this case.
NULL
(same as above).Upvotes: 4