We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20135
    • 188 Posts
    Quote from: sottwell at Jun 10, 2009, 01:26 AM

    A module is not that difficult to write.
    http://sottwell.com/create-module.html
    I wrote a front-end AJAX application to give visitor access to selected rows from the same database:
    http://sottwell.com/article-extjs1.html

    And I don’t consider myself to be a true programming professional, just a self-taught fairly talented amateur. I’m sure you could do much better.

    Hi Sottwell, am wondering if you could help me. I’ve gone through the tutorial you posted above and have developed a fairly full module system. However for some reason, I can’t now integrate the modx DB API functions back into any of my files. For instance, I can’t use $modx->getFullTableNames for any of my querys, and I’ve had to directly access the config.inc.php file to create a new function for accessing the MODx database.

    What would be stopping the module itself accessing any of the MODx DB API functions? In your tutorial, you seem to use them easily enough, and I can’t see any direct references to any MODx document parser files in any of the example files you provided on your website. Can you help?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Are you referring to the AJAX in the back-end? If so, then your AJAX processor files are totally independent of the module itself, and need to include the config.inc.php and document.parser.class.inc.php themselves, and instantiate an instance of a $modx object. I chose not to use the $modx object or the dbapi; I only included the config.inc.php to get the database details and used raw PHP mysql functions.

      You could also put your external AJAX processing code in snippets, and include them in documents, calling the URL to the documents in your AJAX requests. This would make all of the api functions available to you. The documents would have to be published; I would create an unpublished container document to hold them so they won’t get mixed up with actual front-end page documents.

      My site just got a new template, and I’m still working on it, getting the menus and styling organized; the following pages of that series of articles were not exposed yet. They are now; links to the other articles are at the bottom of each page (until I get side menus worked out!)
        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