Quote from: Everett at Sep 23, 2009, 12:14 AM
Or... I also wonder if you couldn’t do something similar that instantiated a new MODx object within a CI library or helper, then just use the same MODx API stuff within that object right inline with your CI controller or model code.
The global modx variable is already available. Just put
into your codeignitor script and then you can access everything.
I actually have never used CodeIgnitor for any projects yet. I just saw some demos and played with some examples. I did this integration to see what would happen. I have yet to try it out for anything serious. I have been wanting to learn a PHP framework for a while, and CI has good documentation, was easier to figure out than Cake, and I hear that it has a very active and helpful community not unlike MODx. I hope that this bridge will encourage CI users to try out MODx, and that there will be some cross-fertilization of ideas between the two projects. CodeIgnitor definately has some good ideas that MODx can learn from, and vice versa (for example, I think MODx handles views better than CI).
For anyone who would rather use CI as a snippet, you can make a snippet and name it ciinc, with this code:
<?php
$cibridge['error_reporting'] = ini_get('error_reporting');
$cibridge['display_errors'] = ini_get('display_errors');
if(isset($_SERVER['PATH_INFO'])) $cibridge['PATH_INFO'] = $_SERVER['PATH_INFO'];
if(isset($_SERVER['REQUEST_URI'])) $cibridge['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
if(isset($_SERVER['QUERY_STRING'])) $cibridge['QUERY_STRING'] = $_SERVER['QUERY_STRING'];
if(isset($_GET['q'])) $cibridge['q'] = $_GET['q'];
if(!isset($path))
$path = isset($_GET['q']) ? $_GET['q'] : '';
$path = '/' . $path;
$_SERVER['PATH_INFO'] = $path;
$_SERVER['REQUEST_URI'] = $path;
unset($_GET['q']);
ob_start();
include('../ci/index.php');
$output = ob_get_contents();
ob_end_clean();
ini_set('error_reporting', $cibridge['error_reporting']);
ini_set('display_errors', $cibridge['display_errors']);
if(isset($cibridge['PATH_INFO'])) $_SERVER['PATH_INFO'] = $cibridge['PATH_INFO'];
if(isset($cibridge['REQUEST_URI'])) $_SERVER['REQUEST_URI'] = $cibridge['REQUEST_URI'];
if(isset($cibridge['QUERY_STRING'])) $_SERVER['QUERY_STRING'] = $cibridge['QUERY_STRING'];
if(isset($cibridge['q'])) $_GET['q'] = $cibridge['q'];
return $output;
?>