Loading MODx Externally

Skip to end of metadata
Go to start of metadata


Loading the MODx Object

Using the MODx object (and all of its respective classes) is quite simple. All you need is this code:

require_once '/absolute/path/to/modx/config.core.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError');

This will initialize the MODx object into the 'web' Context. Now, if you want to access it under a different context (and thereby changing its access permissions, policies, etc), you'll just need to change 'web' to whatever Context you want to load. This also loads the MODX error handler as well.

From there, you can use any MODx methods, functions, or classes.

See Also

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.