TYPO3 流体:如何创建 link 到 PDF 文件(无下载,无显示)
TYPO3 fluid: how to create link to PDF-File (no download, no display)
作为 TYPO3 fluid 的新手,我想知道是否有一种简单的方法可以创建位于文件列表中的 PDF 文件的 link,就像在简单的 html 中一样,如下所示:
<a href="filePathOnServer/file.pdf">Click here to open pdf (in a new window)</a>
到目前为止,我找不到不需要扩展或不会在页面上直接呈现 pdf 的解决方案 (<flux:field.inline.fal name="settings.image" required="1" maxItems="1" minItems="1"/>
)
Should/Can 这可以用 <f:link.external href="filePathOnServer/file.pdf">
完成吗? (我现在遇到另一个问题,无法检查这是否有效...)
编辑
我试过使用 <f:link.external>
但没有用。目前我正在使用(非流体)<a>-tag
...
我不得不做同样的事情,我通过编写自定义 ViewHelper 来解决这个问题,只是为了获取网站 url。
查看助手:
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);
}
}
流体模板:
{namespace ext = Vendor\MyExt\ViewHelpers}
<f:link.external target="_blank"
uri="{ext:internal(path: 'uploads/tx_myext/myfile.pdf')}">
Link
</f:link.external>
作为 TYPO3 fluid 的新手,我想知道是否有一种简单的方法可以创建位于文件列表中的 PDF 文件的 link,就像在简单的 html 中一样,如下所示:
<a href="filePathOnServer/file.pdf">Click here to open pdf (in a new window)</a>
到目前为止,我找不到不需要扩展或不会在页面上直接呈现 pdf 的解决方案 (<flux:field.inline.fal name="settings.image" required="1" maxItems="1" minItems="1"/>
)
Should/Can 这可以用 <f:link.external href="filePathOnServer/file.pdf">
完成吗? (我现在遇到另一个问题,无法检查这是否有效...)
编辑
我试过使用 <f:link.external>
但没有用。目前我正在使用(非流体)<a>-tag
...
我不得不做同样的事情,我通过编写自定义 ViewHelper 来解决这个问题,只是为了获取网站 url。
查看助手:
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);
}
}
流体模板:
{namespace ext = Vendor\MyExt\ViewHelpers}
<f:link.external target="_blank"
uri="{ext:internal(path: 'uploads/tx_myext/myfile.pdf')}">
Link
</f:link.external>