• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Poblem with "default controller" directory (index.php setting) and default_controller

When setting the $routing['directory'] var on index.php without setting controller and function the default controller on config/router.php is buggy, mainly because CI_Router will only load $routing vars just after it calls _set_default_controller that uses $this->directory.

The problems are in the lines 301-305 where it just return if it couldn't find a file. There is no way the $this->directory could be anything besides empty string at this point if enable_query_strings is false. So it could be a test for it and if it's false then set the $routing directory if file not found at line 301 so it could test again. It would be something like that:

PHP Code:
for ($i 0;$i 2;$i++)
           if (file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php')){
           if ($i == && !$this->enable_query_strings && is_array($routing)){
           } else {

I'm currently using this to make a multi-template website with different sets of controllers for each template defined by a EnvVar at index.php with $view_folder and $routing['directory'] vars. That way i share models and others resources between an admin and several frontend applications.

I've just run into this issue, as well. Seems like a simple-enough fix. How do we go about escalating it?

Actually, I'm facing the same problem but with a different issue. The code emiliopedrollo posted is dated now that 3.0 RC3 is out.

At any rate, I've found that my $routing[ 'directory' ] *is* being set, but for some reason by the time I get to line 304, $this->directory isn't set and a 404 occurs.

if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php'))

Back again, already.

The constructor in the Router.php file calls _set_routing() before setting the directory. As a result, the directory isn't set by the time the default controller in a subdirectory is called.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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