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

    My first post; I’m just getting my head around MODx and generally enjoying it, but I have some functionality I need to add and I’m not sure the best way to go about it -- whether I can do what I want with a snippet, plugin or module, or if the core CMF can handle it. Your suggestions would be welcome.

    I am migrating an existing site to MODx. It includes some pages devoted to various products, each with a link or links to PDF downloads. The idea is to get users to register before the first download.

    I had planned to do this with a weblinks and authentication ... so the product page is, say,

    /products/item

    and I’d create weblinks at

    /product/item/brochure
    /product/item/datasheet

    which point to the PDF files inside /assets/docs/pdf. This all works fine (as you can see, I have suffixes set to be blank, which works well).

    My plan was to set up a new web group and require authentication on the weblinks, but it turns out that’s too many hoops -- the client doesn’t want people to have to manage usernames, passwords etc. It doesn’t matter if the downloader fills out bogus details; the intent is to capture details on the way through if possible, but not to discourage downloads.

    So authentication is out, and I can’t see how I could get the weblinks to return a form first if the person hasn’t shared their details yet. (Presumably a cookie would be used to see if they’ve filled out the form.)

    So what’s next? Some kind of combination of eForm and a snippet? Obviously I can read cookies and redirect to the PDF, but you can’t set a cookie when you redirect, and I’m not sure how to render an eForm without losing track of the desired PDF. How would experienced MODxers solve this problem? There are about 45 different PDFs to download so the solution has to scale.

    I hope the above makes sense ...

    Thanks
    Matt
    (Enjoying MODx so far but still on the steep part of the learning curve!)
      • 727
      • 502 Posts
      You say register before the first download - but you don’t want usernames and passwords. What do you want to happen for the second and third downloads? Register each time or use cookies or something like that?

      You can use the callback functions in eform to perform actions when the user submits a form. This can be querying a custom table, etc. or redirecting to a hidden page with the link. But I guess you won’t want someone to later copy and paste the URL into their browser and bypass the form? I guess you could use the callback functions in eform to set up their session data to act just like they logged in as a specific web user that you have predefined, then redirect to a page that’s only accessible for web users.

      Andy
        • 32319
        • 129 Posts
        I would think the simple way to handle this would be to put the download on a secure page that the user would register for an account to access.
          "Regret for the things we did can be tempered by time; it is regret for the things we did not do that is inconsolable."
          -- Sydney Harris
          • 30765
          • 66 Posts
          Quote from: Andy at Jul 08, 2007, 06:09 PM

          You say register before the first download - but you don’t want usernames and passwords. What do you want to happen for the second and third downloads? Register each time or use cookies or something like that?

          Thanks Andy. ’Register’ was a poor choice of word. I want to ask them for email, name, couple other things, but the client doesn’t want them to have to register. No usernames, passwords, etc. And yes, I’d like to use a cookie so they’re not presented with the form again.

          Quote from: Andy at Jul 08, 2007, 06:09 PM

          You can use the callback functions in eform to perform actions when the user submits a form. This can be querying a custom table, etc. or redirecting to a hidden page with the link. But I guess you won’t want someone to later copy and paste the URL into their browser and bypass the form? I guess you could use the callback functions in eform to set up their session data to act just like they logged in as a specific web user that you have predefined, then redirect to a page that’s only accessible for web users.

          I’m not too worried if someone wants to try to work around it; this is supposed to be purely optional. I’ll take a closer look at those callback functions; but I see two problems. One is that browsers won’t accept a the cookie when given an HTTP redirect, so the user would keep being presented with the form. The other is that eForm takes a document ID for redirects, so I can’t redirect to a PDF file, as it won’t have a document ID. (I suppose I could make a weblink for each document, but it’s getting quite involved and would be difficult for the client to maintain.)

          Thanks for your help!
          Matt
            • 727
            • 502 Posts
            What about one document per PDF file? The document contains a download link. Then redirect to each document when the form is submitted.

            Andy
              • 727
              • 502 Posts
              There is a snippet for protecting downloads. I use it on one of my sites. Search for it in the resources - I can’t recall the name right now but it’s an obvious one.

              Andy
                • 30765
                • 66 Posts
                Just to close this ... I decided we were trying to reinvent the wheel, so I’m using MODx’s built-in authentication and an alias to direct to the file I want to download. Works really well. The missing link was realising that the login page should send the user back to the originally-requested file, which it wasn’t; but it turned out that was an easily-fixed bug.

                http://modxcms.com/forums/index.php/topic,16528.msg105658.html#msg105658

                This does mean the user will need to have a username, password, etc, but on balance, I think that’s good. ;-). Thanks for the help.