Thank you for your reply, again!
I spent the last four+ hours digging through the Phoca Download plugin's source code.
It was only at the very end of that work that I discovered (what you probably tried telling me already) that a direct download is essentially a HTTP 303 redirect to the actual file, then handled by the web server. That was my misinterpretation of the "direct link" functionality. But it didn't change the actual problem that I was experiencing (and that I luckily fixed after all that work).
It appears that router.php does not handle the actual download URL. (I don't mean the redirect to the actual file, but the link as it is displayed on the page, regardless whether "direct link" is set to "yes" or "no".) As a result the URL is rendered with a query string, such as:
This is exactly what I am trying to avoid, so I've made some changes to router.php to fix this. I will paste these below, since there does not appear to be an attachment option here.
Code: Select all
} else {
$query['Itemid'] = $itemid;
// Remove the unnecessary URL segments.
unset($query['view']);
unset($query['id']);
unset($query['alias']);
# (Sander) make direct downloads work with SEF:
if(isset($query['download'])) {
$segments[] = 'download';
$segments[] = $query['download'];
unset($query['download']);
}
}
return $segments;
And:
Code: Select all
// Count route segments
$count = count($segments);
# (Sander) make direct downloads work with SEF:
if($count >= 2 && $segments[0] == "download") {
$vars['view'] = 'category';
$vars['id'] = $segments[1];
$vars['download'] = $segments[1];
return $vars;
}
This either means that:
- I made a configuration mistake, and all this code is useless, if I only configured it properly, if I only knew how to configure it properly
- The router.php is in fact flawed, in which case you might want to adopt this change, or you might understand the existing code better and have a better fix
- Something else???
Would you be so kind to review my above code changes and give me some feedback on it? Much appreciated.