Welcome Guest, Not a member yet? Register   Sign In
Loading sub controllers
#1

[eluser]Brandon Dickson[/eluser]
Hello,

I'm relatively new to CI, but I do feel pretty comfortable with it. For the web application I'm developing, I need to load sub controllers into other controllers. Unfortunately I get an error in the loader library when I initialize the new controller.

This is the code for my controller loader, any help would be appreciated.

Code:
<?php
class Controllers
{
    function load( $name )
    {
        $ref_name = end( explode( '/',$name ) );

        $class_name = ucfirst( $ref_name );

        if( isset( $this->$ref_name ) ) return $this->$ref_name;
        
        if( !class_exists( $class_name ) )
        {        
            $path = realpath( APPPATH.'controllers/'.$name.'.php' );
            require( $path );
        }
        
        $this->$ref_name = new $class_name();
        
        return $this->$ref_name;
        
    }
}
?>


Thanks!
-Brandon


Messages In This Thread
Loading sub controllers - by El Forum - 06-03-2008, 08:31 AM
Loading sub controllers - by El Forum - 06-03-2008, 09:14 AM
Loading sub controllers - by El Forum - 06-03-2008, 09:18 AM
Loading sub controllers - by El Forum - 06-03-2008, 10:25 AM
Loading sub controllers - by El Forum - 06-03-2008, 10:28 AM
Loading sub controllers - by El Forum - 06-03-2008, 10:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB