• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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.

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.