Ignore last post, fixed it & it is working a treat!
Ono, thanks for great script!
smileybri....follow these instructions, it works, easy when you know how [I’ve edited/added comments which I hope might help!]...
Sorry if this is a very basic for advanced users...just ignore this post!
1) Create new TV called "FileDownloadFolder" in the MODx Manager. Make sure you tick the box to allow access from the template you are using. Leave everything else blank.
2) Create a new new plugin called "FileDownloadPlugin".
3) Copy and paste "FileDownloadPlugin1.0.php" content from attached zip file
without 1st line "<?php" and last line "?>" into "Plugin code" editbox.
3) Before saving, click on the System Events & tick box for "OnWebPagePrerender" under the Template Service Events section.
4) Press "Save".
5) Create new document called "downloads" if the template that controls this document has access to the TV "FileDownloadFolder" you will see a box you can enter the path to your download folder. For *nix it is the full path on the server...e.g:
/var/www/vhosts/yourdomain.com/httpdocs/assets/files/privatedirectory/
6) On the page that requires a user login, create a link to the file to be downloaded. e.g.
<a href="
http://www.yourdomain.com/index?q=downloads&d=filename.pdf" target="_blank">VIEW</a>
Where "filename.pdf" is the file to be downloaded.
7) Once you have confirmed all is working OK, only then try turning on friendly URLS.
8) I used the default MODX entry for url rewriting in my .htaccess file:
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
9) Login as user & test & then logout & test if file can still be accessed at the same utl:
http://www.yourdomain.com/index?q=downloads&d=filename.pdf
10) When user is logged in, if a blank template page is shown after clicking on the url to your file, check that path to your private download folder is correct (see 5, above).
Thanks everybody for all the helpful posts!