We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20999
    • 20 Posts
    So I have several pages written in PHP that I would like use on a page in php. They are doing a lot of interaction with a database for ordering and configuring products. I want to be able to use my code with a MODx template, so I can easily change the template and such. Anyway, how do you get PHP code to work on a page in MODx? I am just tyring to test it with: <?php phpinfo(); ?>, but nothing shows up.
      • 20999
      • 20 Posts
      I guess I should also point out that I am also JavaScript and PEAR templates along with PHP...
        • 24495
        • 407 Posts
        Create a snippet with your PHP code.
          • 20999
          • 20 Posts
          Nice! Okay thanks. That seemed obvious enough...
            • 36805
            • 354 Posts
            Quote from: nathan at Jul 25, 2007, 11:02 AM

            [...]
            <?php phpinfo(); ?>, but nothing shows up.
            [...]
            For testing a minimal hello-world-like snippet like as I believe you are trying to do try changing it to <?php return phpinfo(); ?> and call the snippet somewhere in your template code or in the rich text editor.

            Snippets that do any kind of output to the website should return it as html code, the MODx parser takes care of the rest.

            I advise you to read this: http://wiki.modxcms.com/index.php/Creating_Snippets. With the php experience you allready have it will probably only take a moment and it explains a lot about snippet coding.