Page 1 of 1
Can't figure out SEF support
Posted: 04 Mar 2014, 07:13
by sanderv
Hi. Great plugin.
But I ran into the problem that URLs like this are causing some problems for my usage (basically if these downloads are to be used from Joomla's "Install from URL" function, Windows users can't have too many
? and
: in there).
When reading on this forum I find a few hints that SEF URLs should be provided, so then why is it that my download page is rendered with a "raw" URL like above?
Even if it is rendered like above, would I be able to retrieve the same file through a SEF URL? If so, how does that URL look? I tried a bunch of possible ideas, but to no avail.
This is the download page that I'm trying to deal with: totaalsoftware.com/downloads/mp3-browser
Your help is much appreciated. Please be kind to me, since I'm trying to offer open source stuff through this download link

Re: Can't figure out SEF support
Posted: 07 Mar 2014, 02:10
by Jan
Hi, on your site, I get no problem with download files? What exactly is the problem?
Jan
Re: Can't figure out SEF support
Posted: 07 Mar 2014, 06:05
by sanderv
Thank you.
Maybe I'm using the terminology "SEF" out of its proper context. The problem that I'm experiencing is that URLs like the one below have a query string (the ? and following) in them:
Code: Select all
http://totaalsoftware.com/downloads/mp3-browser?download=1:mp3-browser-0-3-0-zip
This URL represents a Joomla installation package. If I take the URL and pass it into "Install from URL" in Joomla's Extension Manager it fails. At this point I believe that it is due to the query string. On this forum I read some hints that Phoca download links should be rendered SE-Friendly, which I believe means (among other things) without query string. But I may well be mistaken.
Your help is much appreciated!
Re: Can't figure out SEF support
Posted: 08 Mar 2014, 20:24
by Jan
Hi,
if the url has more than standard parameters, then it gets the ? for adding them. E.g. ?view=category can be translated to SEF but other additional parameters are not more translated. For this feature - translate all possible parameters (including pagination, etc.) you need to create some specific difficult solution (which ten takes a lot of memory to translate the link so it will not be useful)
I have really no idea why a frontend link should be pasted to "install from URL? Which sense it has? Download link is not a direct link which can be used for installation - it is used for download.
So yes, Phoca Download uses standard Joomla! SEF, it uses Joomla! JRoute methods to produce SEF, but SEF does not mean you will translate all the parameters (like e.g. start used in Joomla! for pagination, format=pdf, tmpl=component, etc.) For this you need to run some specific SEF extensions and of course you need to count with higher memory demands.
Jan
Re: Can't figure out SEF support
Posted: 08 Mar 2014, 22:52
by sanderv
Thank you for your reply.
Jan wrote:I have really no idea why a frontend link should be pasted to "install from URL? Which sense it has? Download link is not a direct link which can be used for installation - it is used for download.
Phoca Download allows me to set "Direct Link" to "Yes" for file. This would potentially allow people to copy the direct link and use it in the "Install from URL" of their Joomla instance. (Joomla's new "Install from Web" relies pretty much on the same.) So I'd like to use Phoca Download to offer my downloads, and also to keep track of the download counter, and then have users either:
- Download their package, upload it to their Joomla (which now works fine)
- Use direct download into their Joomla (either through "Install from URL" or "Install from Web"; which works not so well because of the query parameter)
Did I hopefully sufficiently clarify my use case now?
Jan wrote:if the url has more than standard parameters, then it gets the ? for adding them. E.g. ?view=category can be translated to SEF but other additional parameters are not more translated. For this feature - translate all possible parameters (including pagination, etc.) you need to create some specific difficult solution (which ten takes a lot of memory to translate the link so it will not be useful)
So I am still curious to know if there's a way to rewrite
/downloads/mp3-browser?download=1:mp3-browser-0-3-0-zip in a way that does not use the query parameters, or if
download is already considered a "more than standard" parameter.
Much appreciated.
Re: Can't figure out SEF support
Posted: 09 Mar 2014, 21:59
by Jan
Hi, yes, if you will create a direct link, then depends on server if it will be able to give such information for install process of Joomla! and depends on server where Joomla! is installed if it will be able to download the package and depends if the package will be correct format ... but in every case, if you will create direct link, then Phoca Download does not have anything to do if this will be successful or not - then it is a "game" between the first server and second server.
Link - I don't know for now any such SEF solution which can translate all the parameters in URL but you can try to see SEF extensions, maybe some can do this
Jan
Re: Can't figure out SEF support
Posted: 10 Mar 2014, 08:22
by sanderv
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.
Re: Can't figure out SEF support
Posted: 11 Mar 2014, 19:32
by Jan
Hi, thank you for this information but not sure what you handle direct downloads in SEF. Direct download mean, there id direct path to the server file, no SEF url is used, it is direct link to location on server
Jan
Re: Can't figure out SEF support
Posted: 11 Mar 2014, 20:53
by sanderv
Yes, so forget about direct downloads. It took me a while to figure out that my entire issue had nothing to do with direct downloads. I switched off direct downloads, and still had the issue that SEF wasn't working (or at least not the way I think it should work).