Hello. I have MODx Revolution 2.0.8-pl on Apache.
Everything works fine except modx api.
I have php file (
http://eltex-msk.ru/_test.php) with code:
require_once 'config.core.php';
require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
$modx = new modX();
$modx->setLogLevel(modX::LOG_LEVEL_DEBUG);
$modx->log(modX::LOG_LEVEL_DEBUG, 'API START');
$modx->initialize('web');
$prodTemplate = $modx->getObject('modTemplate',1);
if(!is_null($prodTemplate)) echo 'ok';
It works fine. But, if I loged in as admin, on this page I get HTTP 502 (Bad Gateway).
WTF? o_O
In logs only one string:
[2011-04-23 02:24:13] (DEBUG @ /_test.php) API START
Help me please!
for($i=0; $i<100; $i++) echo 'Why is it not working?';
The code you’re using is only for running scripts outside of MODX. Since you’re inside MODX when logged in, it doesn’t work (and isn’t necessary). You definitely don’t want to be using $modx = new modX(); when you’re already *inside* MODX.
If it’s in a snippet, all you need are these two lines:
$prodTemplate = $modx->getObject('modTemplate',1);
if(!is_null($prodTemplate)) echo 'ok';
_test.php - this is an external php file. And it is used for AJAX requests. So what do you suggest does not work of course.
for($i=0; $i<100; $i++) echo 'Why is it not working?';