Hi! I'm having a problem with FileDownloadLink. I'm using it in a getResources tpl to provide direct downloads. The getResources tpl looks like this (it's a table with static resources. I'm providing the link to the resource with FileDownloadLink to hide the path):
<tr>
<td>[[+pagetitle]]</td>
[[!FileDownloadLink?
&getFile=`[[++base_path]][[+content]]`
&tplCode=`
<td><a href="[[+link]]">[[+filename]]</a>
</td><td>[[+date]]</td>`
&dateFormat=`d-m-Y`
&toArray=`0`
]]
</tr>
This works great on most pages but not on a specific resource where there is a get variable in the URL (necessary to show the correct files). The url for this is: www.mywebsite.nl/docs?cat=7
When I click a download link 2 things happen:
- the page reloads but without the variable 'cat' thus the wrong content is shown
- no file is downloaded
I tried to edit core/components/filedownloadr/models/filedownload/filedownload.class.php around line 1008. I added the following to include the var in the download link (thought that might be the problem). I added this:
private function _linkFileDownload($filePath, $hash, $ctx = 'web') {
$link = array();
if ($this->config['noDownload']) {
$link['url'] = $filePath;
} else {
$args = 'fdlfile=' . $hash;
//M2 this part is new
if ($_GET['cat']) {
$args .= '&cat=' .$_GET['cat'];
} // M2 end
$url = $this->modx->makeUrl($this->modx->resource->get('id'), $ctx, $args);
$link['url'] = $url;
}
$link['hash'] = $hash;
return $link;
}
This changes the downloadlink to include &cat=7 at the end but unfortunately the download is still not working, I now get redirected to the not-allowed page.
I might not understand this snippet well enough to find out what is the problem with the download link. Can you help me?