We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49756
    • 7 Posts
    I've been using the WP integration posted here by duncan from codeistry for years with no problems but today when I updated a site to Evo 1.0.15 WP now gives me this error:

    Could not load DBAPI class.

    Any ideas?

    Here is the code I'm using in my WP theme:


    define('MODX_BASE_PATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/');
    
    //define("IN_ETOMITE_PARSER", "true"); // provides compatibility with etomite 0.6 and maybe later versions
    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'] = 'mysql.xxx.com';
    $GLOBALS['database_user'] = 'xxx';
    $GLOBALS['database_password'] = 'xxx';
    $GLOBALS['dbase'] = 'xxx_modx';
    $GLOBALS['table_prefix'] = 'modx_';
    $GLOBALS['base_url'] = 'http://www.xxx.com/';
    $GLOBALS['base_path'] = '/home/xxx/xxx/';
    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; // feed the parser the execution start time
    $modx->tstart = $tstart;
    
    $modx->getSettings();
    $modx->documentMethod = 'id';
    $modx->documentIdentifier = 8; // modx page ID that links to wordpress
      • 36416
      • 589 Posts
      Quote from: lt_dan at Jan 27, 2015, 12:39 AM
      but today when I updated a site to Evo 1.0.15 WP now gives me this error:
      Could not load DBAPI class.
      Any ideas? Here is the code I'm using in my WP theme: (...)

      Bootstrap code for MODX core/parser as of 1.0.13 (from assets/<folder>, change location with dots in first two lines):
      include_once("../cache/siteManager.php");
      define('MODX_API_INC', '../../'.MGR_DIR.'/includes/');
      require_once(MODX_API_INC.'protect.inc.php');
      require_once(MODX_API_INC.'config.inc.php');
      define('MODX_API_MODE', true);
      startCMSSession();
      include_once(MODX_API_INC.'document.parser.class.inc.php');
      $modx = new DocumentParser;
      $modx->db->connect();
      $modx->getSettings(); // provide the $modx->documentMap and user settings
      
        • 49756
        • 7 Posts
        Thanks for the help. So, I would replace lines 27-30 in my code with the code you provided?
          • 36416
          • 589 Posts
          Quote from: lt_dan at Jan 30, 2015, 10:31 AM
          Thanks for the help. So, I would replace lines 27-30 in my code with the code you provided?

          I think that everything up to line 40 needs to go (but not sure, missing a bit of context - what happens after).