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

    A few years ago I created a website using mostly HTML with parts of it written in PHP so I can access and display data from a mySQL database.

    My client has asked me to set up a CMS so they can update the content of the site themselves. My question is - can modX Revo be configured to connect to external data sources for parts of the website content ?

    I have been doing some tutorials that shows me how to set up templates and how to use template variables etc but I have not found any material on the above subject.

    Can anyone point me in the right direction (if it can be done)?

    Thanks
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      PHP in MODX is called up in snippets. So, you'd place your custom PHP code in a Snippet, name it [[mySnippet]], and call up that snippet in the HTML instead of the PHP.

      http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/snippets

      Short answer, yes, MODX can do this. MODX can do just about anything you want it to do.
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 3749
        • 24,544 Posts
        MODX has its own database. It *is* possible to access a separate data source from inside MODX, but you might also want to move the data tables into the MODX database and use the built-in xPDO methods to access it.
          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
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Since MODX connects to its database using PDO (xPDO is a set of extensions to the basic PHP PDO library), you would have to make a separate connection to the database to use the mysqli functions.

          If your site is already using PDO in your database access code, you can use the same code in MODX snippets. The xPDO extension do add a lot of nice data access features, though.
            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
            • 47197
            • 7 Posts
            Thanks for your help guys. Much appreciated.