Welcome Guest, Not a member yet? Register   Sign In
Controllers and subfolders
#1

[eluser]Unknown[/eluser]
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:

Code:
function _remap( $method ) {
        if ( method_exists( $this, $method ) ) {
            $this->$method();
            return;
        } 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 ) ) {
                    $obj->$f();
                    return;
                }
            }
        }

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?

Thanks.


Messages In This Thread
Controllers and subfolders - by El Forum - 07-10-2011, 11:35 PM
Controllers and subfolders - by El Forum - 07-12-2011, 08:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB