We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25519
    • 265 Posts
    I would like to graft an existing php feedback form - which includes a file upload function - into a modx cms site.

    Is this going to cause problems? i.e. will i be able to just copy the code into a new modx template, or do i need to use a more ’bespoke’ form product such as EFORM?

    I would very much like to be able to use the existing form as time is very much of the essence.

    For the record, the existing form is hosted on a server running php version 4.4.7 with reg_globals ON

    thanks in advance
      • 30223
      • 1,010 Posts
      1. You will certainly not be able to just copy and paste the code into a template. You would probably need to refactor the code so that it can run as a snippet. Depending on the the code this might be a simple matter, or could cause major headaches. I’ve experienced both smiley

      2. If your form relies on register globals to be on, I’d forget about even trying. Register globals is evil and you should have it turned off and certainly have no scripts running that rely on it.

      Creating a new form with eForm would probably save you time...
        • 25519
        • 265 Posts
        Hi, thanks for the speedy reply

        I’m thinking that, because of time restrictions, i will need to keep the form outside of the cms in a separate directory, and hard-wire links to the form within the actual modx templates - this won’t be a problem for the client as they won’t need to change these link addresses.

        I guess that I could use absolute url’s from within the cms templates to reach the form. However, I plan to apply friendly url’s to the site after it’s up and running and am a bit concerned about the route back to the cms pages from the form.

        Does this all sound feasible to you - or a recipe for disaster???

        thanks again
          • 30223
          • 1,010 Posts
          You obviously have a path in mind and technically that’s totally possible. I personally wouldn’t go down that path. Having to maintain a separate bit outside the CMS in the long run means more maintenance (as for example when you turn on friendly urls) and potentially trouble reintegrating the form into the cms at a later stage.

          Yes, you may be able to do this to gain a bit of time now but ultimately you should integrate the form in my opinion.

          What’s special about this form that it can’t be translated into a modx form in an hour or two?



            • 25519
            • 265 Posts
            I’d say that there’s nothing special about the form at all - 4 required text fields, 1 required comment box, and a file upload field/button.

            I guess my concern is that, right now, I need to get the site up and running today(!) and will be converting the site into the cms over the next few days. I’ve never used EFORM - would you say that it can implement the above mentioned features? (i’d be surprised if it can’t) and that it is intuitive enough to be able to pick up quickly? I’m fairly adept at figuring out for myself, just rather rushed right now!

            Oh, incidentally as per your earlier comment, reg_globals ON is not a requirement for what i’m doing, it’s just the setting of the clients’ host server (1and1) but forms work fine on their platform. Unfortunately I can’t change the settings.

            thanks again
              • 30223
              • 1,010 Posts
              The standard feedback form which is installed when you choose the sample content while installing MODx would almost do what you describe, besides the upload field. There’s also a couple of examples in the eForm documentation that would help you along pretty quick. Adding file upload is no more than adding an upload field to your form. The uploaded file will automatically be attached to the email that is sent out.

              You could quite easily just copy and paste the existing form’s form into a chunk, add a form id and some eform="" pseudo attributes as well as a form id an you’d be almost set to go. Have a 10 minute read of the eform documentation in assets/snippets/eform/docs/folder and decide for yourself.

              Good luck.

              and if you run into trouble you know where to go smiley
                • 25519
                • 265 Posts
                Thanks for the feedback - it’s really helpful grin

                Implementing eForm sounds fairly straight forward -
                Adding file upload is no more than adding an upload field to your form. The uploaded file will automatically be attached to the email that is sent out.
                does eForm actually have the file upload functionality built in? as I couldn’t tell from the above quote (sorry - i’m a tad busy!!!)

                I won’t be hitting modx for a few days yet until the html site is deployed (which happens today) and maybe tweaked a little. Will I be able to re-post to this thread and get your feedback then if I need it??? (hopefully i won’t need it though!)

                thanks again
                  • 30223
                  • 1,010 Posts
                  does eForm actually have the file upload functionality built in? as I couldn't tell from the above quote (sorry - i'm a tad busy!!!)


                  Yes,... Just read the documentation.
                    • 7231
                    • 4,205 Posts
                    The only thing of note in the form perhaps is the file upload field. Notice that we don’t have to do anything special, eForm will automatically attach the uploaded file to the email it sends out.
                    From what I understand eForm will automatically send the uploaded file as an attachment. To simply upload, without sending it as an attachment, you may need to add a custom event function to handle this, not sure but I guess it would be used with eformOnBeforeMailSent event. I am sure this can be done but I did not find any specific info.
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 3749
                      • 24,544 Posts
                      Quote from: rootsdiv at Oct 18, 2007, 07:36 AM

                      I’d say that there’s nothing special about the form at all - 4 required text fields, 1 required comment box, and a file upload field/button.

                      I guess my concern is that, right now, I need to get the site up and running today(!) and will be converting the site into the cms over the next few days. I’ve never used EFORM - would you say that it can implement the above mentioned features? (i’d be surprised if it can’t) and that it is intuitive enough to be able to pick up quickly? I’m fairly adept at figuring out for myself, just rather rushed right now!

                      Not to speak against eForm, but if your current form is all on one page and posts to itself, you may be able to just paste it into a new snippet, adjust the file paths (make the form action the name of the document containing the snippet call) and put that snippet call on a page.

                      If the current stuff is on separate pages, you need to create separate snippets and place them on separate pages.

                      In either case, if you’re in a hurry, it will probably be faster to hard code all the file paths. Just don’t forget to clean everything up later when you have more time wink

                      Then you could work on porting it to eForm or another solution later.

                      Bob
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting