Posted By

hotdiggity on 03/17/11


Tagged

snippet modx


Versions (?)

Run MODx API in external file


 / Published in: PHP
 

  1. <?php
  2. $path = dirname(__FILE__).'/';
  3.  
  4. define('MODX_SITE_BASE_URL', '/');
  5. define('MODX_SITE_URL', (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off' ? 'http://' : 'https://').$_SERVER['SERVER_NAME'].MODX_SITE_BASE_URL);
  6. $modx_baseurl = MODX_SITE_BASE_URL;
  7.  
  8. include_once($path.'modxapi.php'); //last release of Modx API file located in the root
  9.  
  10. $modx = new MODxAPI();
  11. $modx->connect();
  12. $modx->getSettings();
  13. //$modx->startSession();
  14.  
  15. // Set the base URL for any MODx snippets
  16. $modx->config['base_url'] = MODX_SITE_BASE_URL;
  17.  
  18. //Run snippet
  19. $modx->runSnippet('snippetname');
  20. ?>

Report this snippet  

You need to login to post a comment.