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

    I’m new to MODX CMS , I have installed it and its pretty fine.

    Now I have few doubts regarding my requirement to do.

    I have gone through the documentation of the MODX but unable to understand it.

    I have few PHP based pages which interact with Database and display data . How Can I keep those pages into the MODX CMS .

    Please help me in this regards,

    Thanks in advance,

    Best regards,
    Trinath Somanchi.
    (http://www.myospages.com)
      • 7923
      • 4,213 Posts
      You could try if you can turn them in to snippets. Snippets generally are just php scripts (when you start trying it out, just remove <?php from start and ?> from the end).

      Once you have your snippet ready for testing, just use [!SnippetName!] in some document and see the results. You could also search the forums for IncludeFile snippet and use that to include the php scripts to your pages.

      Or if you want quickly to wrap a complex php program in to your page, you would either install it working on your site in another location and do a Weblink to it and try to theme it to resemble your site as much as possible (think of forums and complex online store applications etc) or you could use a snippet to display them in a iFrame on your site, I think there is a ready made snippet somewhere to do that.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 30636
        • 22 Posts
        Hi Doze,

        Thank you for a prompt reply,

        How can I write a snippet and embbed it in into the MODX CMS. And how can I use the same snippet. Can you please give me any link or any other which gives a details tutorial on Creating and using custom snippets.

        Thanks in advance,

        Best Regards,.
        Trinath Somanchi,
        ( http://myospages.com )
          • 727
          • 502 Posts
            • 30636
            • 22 Posts
            Hi ajayre,

            Thanks for the reply,

            I have gone through the same but unable to proceed further with the help available. Since , Im a new bee , is there any simple tutorial to make my custom snippets. Or Is there any way to embbed my PHP into MODX site so that SESSIONS and COOKIES also work .

            Please help me in this regard,

            Thanks in Advance.
              • 7923
              • 4,213 Posts
              Sessions and cookies works just the same as in your standalone script.. Just try writing some php code to a new snippet and call it on some page. It’s just that simple. Usually snippets collect the output in a string and finally returns it, but now days echo works too (it’s not adviced to use it though, your content could show up in wrong place).

              so instead of

              <?php
              echo ('Your IP is: '.$_SERVER["REMOTE_ADDR"].'.');
              ?>


              do:

              $output =  'Your IP is: '.$_SERVER["REMOTE_ADDR"].'.';
              return $output;
              



                "He can have a lollipop any time he wants to. That's what it means to be a programmer."