We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2136
    • 134 Posts
    ok - i have gotten my head around ContactForm enough to make it work successfully (much thanks to Susan & Ryan). figures that the next thing i want to do involves modifying the snippet and i haven’t had a chance to crack a book on php yet.

    synopsis: we are using a dropdown contact form, visible at www.gatewayyoga.com/home. click on Contact in the nav at the top of the page and voila - a contact form automagically appears. that’s great. the problem is that when the page reloads, that div gets hidden again and you can’t tell whether your msg was sent scuccessfully or not. so what i’d like to happen is the page reloads and the javascript for the sliding action gets run as well so that you can see the response to the attempted message send.

    i’m assuming this can be done by modifying the snippet, but my assumption is based on zero current knowledge of php. is there a way to make the javascript link run as part of the snippet? (that’s href="javascript:Effect.Combo(’contactwrapper’);" ) the workaround is to make a redirect page (which is what we’re doing with the splash page currently up in the site root) but that doesn’t help with errors.

    much thanks!
      Sorry - not using ModX anymore 01/01/2007
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Clever. What I would do is is add a placeholder to the snippet that only gets set on completion, and use that placeholder in your template in the header and position it just below the "yoga". Placeholders are great, you can put them wherever you want on your page.

      Put this with the rest of the success stuff:

      $successmessage = '<div id="successMessage'>Message sent! Thank you.</div>';
      $modx->setPlaceholder('successMessage', $successmessage);
      


      Now put the placeholder [+successMessage+] where you want, and style and position it with your CSS.
        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
        • 2136
        • 134 Posts
        so this would be a div that would only appear if the successmessage is called? it would be kinda like the hidden sliding div action? if so, then i could also create another placeholder for a failure message like ’you left one of the fields blank,’ correct?

        thanks again.
          Sorry - not using ModX anymore 01/01/2007
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Indeed; eForm already does that, it has a placeholder for an error message.
            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
            • 2136
            • 134 Posts
            ah - that’s great. i can poke around the eForm code and see how it’s done. thank you!
              Sorry - not using ModX anymore 01/01/2007
              • 2136
              • 134 Posts
              ok - this is bit beyond me. i added the success stuff to the snippet like so

              // Success Message
              $success = "Thanks for contacting [(site_url)]. Someone will get back to you soon. You may submit another message in the form below.";

              // Class for containing Success Message <p>
              $successClass = "message";

              // SUCCESS MESSAGE PLACEHOLDER SHIZZAZZLE
              $successmessage = ’<div id="successMessage’>Message sent! Thank you.</div>’;
              $modx->setPlaceholder(’successMessage’, $successmessage);

              and added [+successMessage+] to my template right above the content area. did this require more personalizing or modification? i tested and nothing happened.
                Sorry - not using ModX anymore 01/01/2007
                • 10487 MODX Staff
                • 1,535 Posts
                Not sure if this is causing the issue but check the quotes on the $successmessage statement, there’s a single quote at the end of the ’id’ attribute that should be a double quote, like:
                $successmessage = '<div id="successMessage">Message sent! Thank you.</div>';
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Yes, it’s a very bad idea to copy/paste any of my off-the-cuff code, I’m dyslexic and have to double- and triple-check my punctuation and numbers, especially.
                    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
                    • 2136
                    • 134 Posts
                    i’ll remember that in the future wink

                    still nothing. i guess just adding the code isn’t the way to go?
                      Sorry - not using ModX anymore 01/01/2007
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      // Success Message
                      $success = "Thanks for contacting [(site_url)]. Someone will get back to you soon. You may submit another message in the form below.";

                      // Class for containing Success Message <p>
                      $successClass = "message";

                      // SUCCESS MESSAGE PLACEHOLDER SHIZZAZZLE
                      $successmessage = ’<div id="successMessage’>Message sent! Thank you.</div>’;
                      $modx->setPlaceholder(’successMessage’, $successmessage);

                      You have your variable named $success, but you set a placeholder using $successmessage.
                        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