We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8912
    • 11 Posts
    Hi,

    Not sure if this is the right place to add this query but,
    I cant seem to find a way to have people fill out a form before allowing them to download a file.

    I have a resource category with several TV’s one of them a pdf, the idea is to offer the pdf for download only after a webform (eForm) is filled out containing only name and email field, receive the data from the form to my email including the actual downloaded file name and page ID, not simply a link to download.
      • 8912
      • 11 Posts
      huh any one that can help me out? embarrassed
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        So basically the "thank you" on submission of this form would contain the URL for downloading the file? And you want the report that you get to have the filename, as well as the data from the form?

        How, exactly, is the file offered? Does each file have its own page, with its own call to eForm? Or is there a list of files they can choose from, with one form for all of them?
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 8912
          • 11 Posts
          Hi Sotttwell, thanks for your reply

          Quote from: sottwell at Dec 03, 2009, 02:03 PM

          So basically the "thank you" on submission of this form would contain the URL for downloading the file? And you want the report that you get to have the filename, as well as the data from the form?
          Exactly what I would like to get.

          Quote from: sottwell at Dec 03, 2009, 02:03 PM

          How, exactly, is the file offered? Does each file have its own page, with its own call to eForm? Or is there a list of files they can choose from, with one form for all of them?
          The pdf brochures are added in a TV on each individual product page, each product page has it own pdf file, for now there aint even a call to eForm on those pages just a plain ’Download Brochure’ link.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Ok, this is doable. Let me think about it a bit, and I’ll run some tests on my localhost and get back to you.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Would you please post an example of an abbreviated document content including a link, and the TV you’re using to make the link?
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 8912
                • 11 Posts
                The TV is used by the product template and is called [*pdf*]
                not sure what you meen with abreviated document content.
                Link to a page containing the download link is ofcourse no problem
                http://www.investmentandrealestate.com/macaiba.php DL link bottom right wink
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  For the thank-you form you can simply add a line to the thankyou tpl like this:
                  <p>You may now <a href="assets/files/[*pagetitle*].pdf">download this product's PDF file.</a></p>

                  using any TV you like. Using a file input type TV, omit the assets/files and the .pdf part. If your pdf TV is using an output widget, omit the <a> tags. In other words, adjusts the link to reflect whatever your TV is generating.

                  I’ll have to repeat this on my remote site to see how the report tpl works, as I haven’t bothered to set up email on my localhost.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Well, I meant the raw document content from the Manager, but it’s not necessary. TVs can be used in the eForm chunk tpls (at least so far I know for sure they work in the thankyou tpl).
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      I should have guessed this was too easy; of course the TV tag doesn’t work in the report form; it gets used as-is by eForm and never gets passed through the parser.

                      There are two ways to handle this; you can add a hidden field to the form, or use an event with a custom snippet to add to the $fields array so you can use a placeholder in the report. Personally, I’d go with the hidden field. You’ll be using the same form tpl for all the product pages, so it’s not a big deal.
                      <input type="hidden" name="pdf" value="[*pagetitle*]" eform="::0::" />

                      If you’re using a Hyperlink output widget for the TV, you don’t want to use the TV here since it generates a relative hyperlink, so the product’s pagetitle should do the trick. Now in the report tpl you can just put
                      <strong>Product: </strong>[+pdf+]

                      or whatever enclosing HTML will go with the rest of your report, using the placeholder for whatever you name that hidden input field as. Make sure to specify the non-validating eForm attribute, otherwise eForm will run a validation on all hidden input fields and complain if it’s different from the form tpl (and the actual value will of course be different from the original MODx tags) to protect from form hacking. Of course, if this were going into a database you would have to provide your own careful validation of its value for the same reason.
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org