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

    as explain at http://rtfm.modx.com/display/revolution20/Loading+MODx+Externally, I was created the standalone.php script to generate ajax data (json, html, or other), but when I want to do a $modx->runSnippet('getResources', array(...)) is there an error I cannot reach, I don't know why, the parameteres are all okey, testing under a standard use.

    This simple exemple (other snippet than getResources) is not working :
    // standalone modx code
    $o = $modx->runSnippet('Wayfinder',array('startId'=>0));
    echo $o;
    

    a 500 internal server error return under my browser (using Chrome).

    Why ?
      • 22303 MODX Staff
      • 10,725 Posts
      You should be able to see the 500 error either in core/cache/logs/error.log OR in whatever is configured as your PHP error_log (typically this is the Apache error log).

      That said, loading MODX externally is not really recommended if you want to execute Snippets intended to be executed on a specific Resource. Many of them require the proper Context and Resource to be setup and loaded (with all the related data used in the request handling) in order to work properly.

      Rather than struggling with this external loading scenario, why not create Resources in MODX to handle your AJAX requests? This makes things more consistent, reduces the possibility you might introduce additional attack vectors for hackers, and allows you to take advantage of the entire MODX framework more easily.
        • 36826
        • 4 Posts
        Well, loading modx externally it's not recommended ?, well why this tuto explain this, if it's more secure to do it under the modx way !

        also, Thanks, I will change the way to perform json return (ajax dialog).
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: lowcraft at Sep 19, 2011, 10:10 AM
          Well, loading modx externally it's not recommended ?, well why this tuto explain this, if it's more secure to do it under the modx way !

          also, Thanks, I will change the way to perform json return (ajax dialog).

          I said it's not recommended "if you want to execute Snippets intended to be executed on a specific Resource." There are perfectly valid reasons for loading the modX class externally, I am just trying to clarify that it is not necessary to execute AJAX requests; they can be created as Resources.
            • 36826
            • 4 Posts
            Well, it's done, ajax working under resources now, and... no prob.
            Thanks !