Reputation: 154
First, here is the Typoscript :
20 = TEXT
20 {
value {
field = field_title
wrap = |.txt
}
filelink {
stdWrap.wrap = <li>|</li>
path = fileadmin/txt-files/
}
}
The result I get is :
<li>
<a href="/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
And what I need is :
<li>
<a href="/fileadmin/force_download_script.php?filepath=/fileadmin/txt-files/Title.txt">
<img src="typo3/sysext/frontend/Resources/Public/Icons/FileIcons/txt.png">
</a>
</li>
I need to make the link downloadable, rather than opening the file in the browser. For that I have a force_download_script.php
, but when I do that :
wrap = fileadmin/force_download_script.php?filepath=|txt
instead of the current wrap, filelink
doesn't find the file anymore.
I have tried using ATagBeforeWrap.wrap
but it doesn't look like it's made for that purpose. I also tried typolinkConfiguration.wrap
without any success.
Any idea of how to achieve that ? Using a COA maybe ?
Thank you !
Upvotes: 0
Views: 732
Reputation: 6164
To use the TYPO3 core solution with file links you can use this guide:
Unfortunately I can't find any official documentation for this feature, but will post it when I find something or wrote it myself. ;)
Maybe this can help you, too: https://extensions.typo3.org/extension/fal_securedownload/
Here is the official part, but it's not much: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Fal/Administration/Storages.html?highlight=filedumpcontroller
Upvotes: 0
Reputation: 4565
I would not do this with a script, but with server configuration. If you use Apache and have .htaccess enabled, you can add the configuration to a .htaccess file in the directory where the files are located. See https://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/
Alternatively you can also use the HTML5 download
attribute. This is not supported by Internet Explorer however (it is supported by Edge though).
Upvotes: 1
Reputation: 10790
Are you sure .filelink
is what you are looking for?
.filelink
is for a set of files. For all files in the folder given by .path
a link will be generated. see manual
From your description you want a text wrapped with a link to one single file. That would be more a problem for .typolink
where you specify the link in .parameter
.
if you really want a link list of multiple files, each wrapped with your script you need to modify .typolinkConfiguration.parameter
which will be used internaly by .filelink
.
Anyway it might be possible to do a wrap which then would be:
.typolinkConfiguration.parameter.wrap = /fileadmin/force_download_script.php?|
Maybe it is easier to build your list with .stdWrap.filelist
, where you can use the filenames in any way to wrap your own href parameter for an A-tag.
Upvotes: 0
Reputation: 6084
The issue can get quite a bit complicated, but step by step:
wrap = fileadmin/force_download_script.php?filepath=|.txt
txt
was missing.typo3conf/LocalConfiguration.php
respectively some settings in the install-tool.The admin-panel might be useful to debug some things about your script but if not you've to include some debug-output first in your own code, if that's not enough in the core (temporary).
So you've to find out if your script is triggered and if not, the reason for it.
Upvotes: 0