[eluser]Jeffrey04[/eluser]
This is roughly how I manage to integrate my drupal 5.7 installation and CI..... requires a bit of hacking that I have no idea whether I am doing things correctly. So use this at your own risk
1. First create a folder named 'ignited_drupal' in your sites/all/modules.
2. Then paste the following files into the folder.
3. Put your application folder and index.php into the folder and place your system folder elsewhere
4. Remember to config your index.php and config.php
ignited_drupal.info
Code:
; $Id$
name = "Ignited Drupal Project"
description = "Integration of Code Ignited PHP framework and Drupal"
package = _CodeIgniter
ignited_drupal.module
Code:
<?php
define('IGNITED_DRUPAL_TRIGGER', 'app');
/**
* Ignited Drupal help topics
*/
function ignited_drupal_help($path) {
$help_text = '';
switch($path) {
case 'admin/help#ignited_drupal':
$help_text = t('Ignited Drupal is a module to integrate
<a href="http://www.codeigniter.com/">CodeIgniter</a>
and <a href="http://www.drupal.org">Drupal</a>.');
break;
}
return $help_text;
}
/**
* To set the permission to access the ignited_drupal installation
* root page
*/
function ignited_drupal_perm() {
return array(
// define whether one can access to the root
'access ignited_drupal root'
);
}
/**
* To set the menu items
*/
function ignited_drupal_menu() {
$items = array();
// the root of the installation
$items[] = array(
'path' => IGNITED_DRUPAL_TRIGGER,
'title' => t('Additional applications'),
'callback' => 'ignited_drupal_start_app',
'access' => user_access('access ignited_drupal root'),
'type' => MENU_CALLBACK
);
return $items;
}
/**
* Start the codeigniter application
*/
function ignited_drupal_start_app() {
ob_start();
_ignited_drupal_process_request($_GET['q']);
require dirname(__FILE__) . '/index.php';
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/**
* Theme the codeigniter application
*/
function theme_ignited_drupal($content) {
print theme('page', $content);
}
/**
* Process the request into codeigniter understandable format
*/
function _ignited_drupal_process_request($query) {
// take out the first portion of query
$start_length = strlen(IGNITED_DRUPAL_TRIGGER . '/');
if(strpos($query, IGNITED_DRUPAL_TRIGGER . '/') !== FALSE) {
$query = substr($query, $start_length);
} else {
$query = '';
}
$_SERVER['PATH_INFO'] = $query;
}
/**
* Populate the $_GET array to enable codeigniter to redirect
* request
*/
function _ignited_drupal_set_param($param, $index, $key) {
if(isset($param[$index])) {
$_GET[$key] = $param[$index];
}
}
Activate the drupal module, and then you can access your CI application using the address ?q=app/<controller>/<method>
However, you will probably get some error messages from PHP that CI system files are calling methods from non-object.
For example in the system/libraries/Output.php
Code:
global $BM, $CFG; // this would return null object
$BM =& load_class('Benchmark'); // so I load the object using &load;_class
$CFG =& load_class('Config');
I have also did the similar hack to some other system files.
I am not sure whether this hack is appropriate, please comment