Welcome Guest, Not a member yet? Register   Sign In
Ignited Drupal
#1

[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 Tongue
#2

[eluser]xwero[/eluser]
I wonder if you use drupal why you need CI? Wouldn't it be better/easier to extend drupal?
#3

[eluser]Jeffrey04[/eluser]
[quote author="xwero" date="1212491803"]I wonder if you use drupal why you need CI? Wouldn't it be better/easier to extend drupal?[/quote]

I am not the one who made decision Big Grin Anyway developing in CI is much easier than developing in drupal
#4

[eluser]wan-geek[/eluser]
Any thoughts on what may be causing this not to work w. 6.14? I have followed the instructions up to the 'activation' section, but run into this:

Code:
Ignited Drupal Project        Integration of Code Ignited PHP framework and Drupal
This version is incompatible with the 6.14 version of Drupal core.

I'm -really- hoping to get my CI app pieces integrated into Drupal. I love the advantages that Drupal has to offer, and don't want to have to reinvent all this functionality w. every CI project, but need to be able to get my CI code integrated.

I've tried just using iframes and the like, but those techniques suck to be honest.

If there's any reading you can point to as to how to get this playing together, I'd love to understand further what's all going on to tie the two together.

Please lend me a hand so that I can research this further and code this glue. Any pointers/docs are greatly appreciated.

Cheers,
-Chris
#5

[eluser]Colin Williams[/eluser]
CodeIgniter's entry point is the front controller. Drupal routes requests via the menu system. So, just make a drupal module with dynamic menu callbacks that load up CI's front controller.

But I think it's a bad idea from the start. Just become a better Drupal developer.
#6

[eluser]wan-geek[/eluser]
Thanks for the leads.

I completely agree about doing it the 'drupal' way, but for the moment I just want to get the pieces I already have in CI working in concert to buy me time to re-code everything in a different manner. I know it's not enormously difficult or anything, but not having done drupal development before it's going to take me a minute to get up to the same speed.

I definitely appreciate the explanation and will read-up on the topics.

Cheers,
-Chris
#7

[eluser]Jeffrey04[/eluser]
[quote author="wan-geek" date="1257132297"]Thanks for the leads.

I completely agree about doing it the 'drupal' way, but for the moment I just want to get the pieces I already have in CI working in concert to buy me time to re-code everything in a different manner. I know it's not enormously difficult or anything, but not having done drupal development before it's going to take me a minute to get up to the same speed.

I definitely appreciate the explanation and will read-up on the topics.

Cheers,
-Chris[/quote]

the module is now completely abandoned, but you may port it to D6.x by changing a couple of function calls. We actually ported this to use with another similar framework... however, after months of working with it, almost everyone thinks that this is not a good idea though Big Grin




Theme © iAndrew 2016 - Forum software by © MyBB