CodeIgniter Forums

Full Version: Controllers and subfolders
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I've searched the net and found nothing about this for v2.0.2, and the ways I found for v1.x are pretty hacky too. I came up with the following, which seems to kind of work:

function _remap( $method ) {
        if ( method_exists( $this, $method ) ) {
        } else {
            $p = str_replace('.php', '', __FILE__) . '/';
            if ( file_exists( $p . $method . EXT ) ) {
                include_once( 'admin/' . $method . EXT );
                $obj = new $method();
                $f = $this->uri->segment( 3 );
                if ( $f == 'list' ) { $f = 'show'; }
                if ( method_exists( $obj, $f ) ) {

In my case, the Controller class is 'Admin', hence the hardcoded 'admin/' directory.

However, when doing this, it seems that the autoloaded session's library is not available. Is there an easy step that I'm missing? Or is there another way to make subfolders and controllers work well together?


El Forum

[eluser]Eric Barnes[/eluser]
I am not sure I follow. How many subfolders you want? Just one or ten deep?