Being new to TYPO3 fluid I was wondering if there's an easy way to create a link to a PDF-file which is located in the filelist as you would in simple html as follows:
<a href="filePathOnServer/file.pdf">Click here to open pdf (in a new window)</a>
I couldn't find a solution so far that wouldn't require an extension or that wouldn't render the pdf direclty on the page (<flux:field.inline.fal name="settings.image" required="1" maxItems="1" minItems="1"/>
)
Should/Can this be done with <f:link.external href="filePathOnServer/file.pdf">
? (I've got another problem at the moment preventing me from checking if this works...)
EDIT
I've tried using <f:link.external>
which didn't work. For the time being I'm using the (non-fluid) <a>-tag
...
I had to do the same thing and I resolved it by writing a custom ViewHelper just to get the site url.
ViewHelper:
class InternalViewHelper extends AbstractViewHelper
{
/**
* Renders a link to a specific path from the root path of TYPO3.
*
* @param string $path The path to an internal resource relative to the TYPO3 site URL.
* @return string The absolute URL to the given resource.
*/
public function render($path)
{
$siteUrl = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
return htmlspecialchars($siteUrl . $path);
}
}
Fluid Template:
{namespace ext = Vendor\MyExt\ViewHelpers}
<f:link.external target="_blank"
uri="{ext:internal(path: 'uploads/tx_myext/myfile.pdf')}">
Link
</f:link.external>