We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8592
    • 22 Posts
    I have some external scripts for handling Ajax requests. How can I access $modx object in these scripts?? huh

    Should I make them as individual snippets? sad embarrassed
      I love computer programming...
      • 20400
      • 37 Posts
      Try this:

      require_once(MODX_BASE_PATH . 'manager/includes/document.parser.class.inc.php');
      $modx = new DocumentParser();


      The document parser loads the DBAPI, so you can access the database as well as the document.parser functions. The only problem I have had is the getting information from the cache, such as getting a Chunk. These settings are not loaded by default. Just run
       $modx->getSettings(); 
      to load the information.
        • 26435
        • 1,193 Posts
        Quote from: mregan at Aug 25, 2007, 10:30 PM

        Try this:

        require_once(MODX_BASE_PATH . 'manager/includes/document.parser.class.inc.php');
        $modx = new DocumentParser();


        The document parser loads the DBAPI, so you can access the database as well as the document.parser functions. The only problem I have had is the getting information from the cache, such as getting a Chunk. These settings are not loaded by default. Just run
         $modx->getSettings(); 
        to load the information.

        Or, if you are using MODx 0.9.6, you can just include index.php!
        This was a new feature put in to 0.9.6. (see this post), but there is a small problem in index.php (around line 130). I had to comment out, or remove the "exit;".

        -sD-
        Dr. Scotty Delicious, Scientist DFPA.
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages