MODxIt seems like there is always a lot of great work being posted in the MODx forums and on Twitter. This solution by netProphET caught my eye since I am always looking for techniques that create a tighter front-end integration between scripts.

As soon as I saw this solution I knew we had at least 3 projects that this could quickly implemented on:

/**
 * this goes at the top of a WP theme template file, e.g. footer.php
 */

// next line assumes that modx is installed in site root, and WP is a subdirectory off root (e.g. /blog/)
define('MODX_BASE_PATH'dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/');

define("IN_PARSER_MODE""true");
define("IN_MANAGER_MODE""false");

if (!defined('MODX_API_MODE')) {
    define('MODX_API_MODE'true);
}

// initialize the variables prior to grabbing the config file
$GLOBALS['database_type'] = 'mysql';
$GLOBALS['database_server'] = 'localhost';
$GLOBALS['database_user'] = 'xxxxxxxxxx';
$GLOBALS['database_password'] = 'yyyyyyyyy';
$GLOBALS['dbase'] = 'zzzzzzzzzz';
$GLOBALS['table_prefix'] = 'modx_';
$GLOBALS['base_url'] = 'http://www.xxxx.com/';
$GLOBALS['base_path'] = '/home/xxxx/public_html/';
define('MODX_BASE_URL'$GLOBALS['base_url']);
define('MODX_SITE_URL'$GLOBALS['base_url']);

$ipath ini_get('include_path');
ini_set('include_path'$ipath ':' $GLOBALS['base_path']);

// initiate a new document parser
include_once($GLOBALS['base_path'].'manager/includes/document.parser.class.inc.php');
$GLOBALS['modx'] = new DocumentParser;
$modx =& $GLOBALS['modx'];
$etomite = &$GLOBALS['modx']; // for backward compatibility

// set some parser options
$modx->minParserPasses 1// min number of parser recursive loops or passes
$modx->maxParserPasses 10// max number of parser recursive loops or passes
$modx->dumpSQL false;
$modx->dumpSnippets false;
$modx->tstart $tstart// feed the parser the execution start time

$modx->getSettings();
$modx->documentMethod 'id';
$modx->documentIdentifier 10;

// header
$modx_header$modx->rewriteUrls($modx->parseDocumentSource('{{Header}}'));
// footer
$modx_footer$modx->rewriteUrls($modx->parseDocumentSource('{{Footer}}'));
blog comments powered by Disqus