-
☆ A M B ☆
- 24,524 Posts
I would create a custom "Content Type" for PDF files, and use a static resource for the file download.
http://rtfm.modx.com/display/revolution20/Content+Types
http://rtfm.modx.com/display/revolution20/Static+Resource
Then I would have the form, using post-hooks to store and/or email the data, then have the redirectTo resource actually be the static resource.
http://rtfm.modx.com/display/ADDON/FormIt.Hooks
http://rtfm.modx.com/display/ADDON/FormIt#FormIt-AvailableProperties
Now as soon as the form is successfully submitted, the user will get the usual download dialog for the .pdf file. The URL will be to the static resource, not to the file itself, thus providing some protection for your files. They can even be outside of the web root for more serious protection.
thank you sottwell, super helpful. My only remaining concern is how to get around asking the user to fill out the form for every pdf download i.e after they have successfully downloaded one.
-
☆ A M B ☆
- 24,524 Posts
Ah. That's another matter. Are you referring to a login? Or just being able to download files during that single session?
A single session would be fine.
-
☆ A M B ☆
- 24,524 Posts
There are several ways to do that. One way would be to set a $_SESSION variable on successful submit with a post hook, and have the redirectTo be a real page with download links, again to static resources with custom content types, and only users with that $_SESSION value set can access the page - almost like a proper "protected" page only without getting into logins and MODx users. These links won't lead to other pages, being custom PDF types, they'll open the download dialog (or open the .pdf file in the browser's PDF reading plugin), while the user will remain on the original page with all the links.
Hi, i have used the approach above to allow a user to download T&Cs if they enter their name and email address in a formit form (by redirecting to a static resource referencing a PDF file). This works fine for me in Firefox and IE but does nothing on an ipad/iphone - the PDF is not displayed and the page redirects to my home page (even though the PDF address is given as the URL).
I found it interesting as well that in Firefox the PDF is displayed to me within the browser but in IE the PDF is displayed in Adobe PDF viewer and not within the browser itself.
Does anyone know anything about the way Firefox, IE and Safari handle PDFs and why the above may be happening?
My customer is telling me as well that he is not able to download the T&Cs from IE or Firefox at all. It all seems to be behaving very strangely, but perhaps i am missing something?