Extbase FileReference Screen with Liquid

In extbase extension, I have a FileReference object. It was built with extension_builder originally. From the model:

/**
 * apprenticeshipDocument
 *
 @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
 */
protected $apprenticeshipDocument = NULL;

      

and etc.

The interface <f:debug>{institution.apprenticeshipDocument}</f:debug>

gives me the following:

Extbase Var Dump

First thing: originalResource

missing.

Second: When calling {organization.apprenticeshipDocument.uidLocal} directly, the value is NULL! Although he said he is above 450.

Third: let's say we could get a uidLocal that matches the uid in sys_file.

Googlable solution:

<f:link.page pageUid="{f:uri.image(src:450)}" target="_blank">Text</f:link.page>

      

does not point to the PDF file itself, but to the rendered GIF PDF. All I want to do is output the file path ( sys_file.identifier

) in the link ... there must be a way, right?

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>

      

+3


source to share


1 answer


Files and file links behave a little differently than usual:



  • They are lazy, so the values ​​for originalResource

    (Extbase file reference) and originalFile

    (main file values) NULL

    before the first access to them. But you can just access them as usual.
  • Cannot get the value of uidLocal

    an extbase file link 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 attribute publicUrl

    or use the ViewHelper v:link.typolink

    from EXT: vhs, for example:

    <v:link.typolink configuration="{parameter: 'file:{uid}'}>
        Linktext
    </v:link.typolink>
    
          

    uid

    is the file identifier in this case.

  • Many file properties (especially metadata properties) are not stored as normal object attributes, but are internally stored in an associative array and then retrieved using a magic getter. They are also lazy. Thus, they usually do not appear as separate properties in variable dumps and may not be set at all or NULL

    (as stated above).
+4


source







All Articles