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

    I'm having issues with a mail form on my website.
    It's nothing unusual and nothing I've never done before.
    However, I keep getting the mail sent to me twice.

    After some experimenting (adding a random mail function in a snippet on a different page, where there's no form or anything), I've come to the conclusion that every page seems to load twice by default.
    As far as I know, there is no reason for that to be. And I would assume that is not supposed to be happening either.

    So my question to you guys is: is it normal for every page to loaded twice?
    And if not: what could be the cause of this? Or simply: what should I do about it?

    Thanks in advance for the help!

    This question has been answered by dizero. See the first response.

      • 48589
      • 33 Posts
      Note: I've also tried unsetting the $_POST after the first execution. That prevents the mail from being sent a second time, but...
      That, to me, is a work-around and not a solution to the actual problem (loading twice, which also would create more stress on the server, so not a good thing IMO).
        • 3749
        • 24,544 Posts
        Do you maybe have a plugin or snippet on the page (or in the template) that could be doing it? -- especially a plugin tied to one of the resource events.

        The other places to look would be .htaccess and the main index.php file (in case you've been hacked).
          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
          • 48589
          • 33 Posts
          Thanks BobRay for the quick reply. A hack should be almost impossible, as it was there right after I installed Revo. So to answer the first part of your question:
          - The only plugin I use on the install as a whole, is the ACE editor. So that shouldn't be doing anything on the website itself, right?
          - Snippets that are running on every page as part of the template (from the 'Bootstrap' extra) are Wayfinder and If. And I don't think there's anything special about those.
          - The .htaccess file is perfectly normal.

          Like I said, it also occurs on pages that don't have the form handling snippet, so that one shouldn't be the problem either.

          So unless anyone else is aware of any issues with that Bootstrap Extra, I don't think any of the possible causes you've mention could be the issue. But I've got another website using pretty much the same setup, so I'm gonna check and see if that one has the same issue. I don't think it does, though.
            • 48589
            • 33 Posts
            Now having tried several other sites all on the same hosting account/server, all using the same version of Revo, all using the Bootstrap extra, I noticed: it also happened on 2 of the 4 sites tested (although one that didn't have the problem, also didn't have Bootstrap).

            What I'm gonna do next is completely take all the content down. And then piece by piece put everything back in there (of course I have a back up) to see at what point the issue starts to occur.
            • discuss.answer
              • 48589
              • 33 Posts
              Ah, I finally got it.
              The issue was part of the Bootstrap template after all.

              There's the following If statement:
              [[!If?
              	&subject=`[[RenderSidebar]]`
              	&operator=`!empty`
              	&then=`<div class="row">
              		<div class="col-md-2 sidebar-offcanvas" id="sidebar" role="navigation">
              			[[$Sidebar]]
              		</div>
              		<div class="col-md-10">
              			[[*content]]
              		</div>
              	</div>`
              	&else=`[[*content]]`
              ]]


              And that doesn't really load one (like the statement would imply), it loads both for some weird reason.
              Since I'm not using the sidebar at all, replacing it with the code below seems to do the trick:
              [[*content]]
                • 3749
                • 24,544 Posts
                I can't see anything that would make that code double the content, but I'm glad you got it sorted. smiley
                  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
                  • 48589
                  • 33 Posts
                  My guess would be that somehow it doesn't actually run like a proper if-statement.
                  But like I said: I'm not even using the sidebar, so I'll leave it to someone else to delve further into that wink