We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24480
    • 3 Posts
    I have only recently taken up Modx and I keep running into a problem,
    And I hope someone on here is able to point me in the right direction.

    I was working on a website and made a template of my contactform. everything before putting it into Modx was working fine except Modx can’t seem to find the other php files I include. I guess when making templates modx copies them to a other directory, anyone knows where I can find them?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      How are you including the external .php files? In MODx, since the templates are stored in the database and are processed through the MODx parser, you cannot use the PHP <?php ... ?> construct. All PHP code must be in a snippet (or a TV with @EVAL binding or a plugin, but those are different matters).

      In the Manager, go to Elements->Manage Elements, then the Snippets tab. Click the "New Snippet" link, and put your snippet code there.
      include "assets/snippets/mysnippetfiles/whatever.inc.php";

      Then in your template, use the snippet tags [!mysnippet!] where you want the output of your snippet to appear.

      http://www.sottwell.com/how-snippets-work.html

      That said, you should really consider the eForm snippet, which comes with the default installation of MODx. It has good introductory documentation included in the assets/snippets/eform/docs directory.

      http://wiki.modxcms.com/index.php/EForm
        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
        • 24480
        • 3 Posts
        Hi Susan,
        Thanks for your reply!

        Well basically im calling the .php file by using a form action, I have made a snippet as you told me to but I can’t get it to work yet, I will keep experimenting for a bit and see if I can get it to work.

        As for the default Modx Eform, that would be a good recommendation and I will keep it in mind, but I had already made a decent and secure contact form, so I will try to stick with the form as it is but for future creations I will definitely look into them!