Welcome Guest, Not a member yet? Register   Sign In
Multiple controller sub folders
#1

[eluser]Timothy_[/eluser]
Hello,

My codeigniter site has grown rather large and i am in need of multiple sub folders for my controllers. I am already using one layer of sub folders successfully but get 404 errors if i add another 'level' of folders within my controller directory.

So 'folder/controller.php' works and 'folder/folder/controller.php' throws a 404.

In my searches i found a bug report describing this. Can someone please confirm that this is still the case.

Thanks,
Tim
#2

[eluser]Buso[/eluser]
wow, I would like to see that site if that's not a problem Smile
#3

[eluser]Timothy_[/eluser]
Sure,

I'll send you a link once we go live!
#4

[eluser]Buso[/eluser]
I don't know about CI 1.72, but it doesn't work on CI 2.0, so I don't think it ever did

You can try hacking or extending Router.php library, its human-readable

Look for _validate_request method
#5

[eluser]mddd[/eluser]
CodeIgniter doesn't support more than 1 level of folders out of the box.
You could probably make it do so yourself, like Buso says.
#6

[eluser]Unknown[/eluser]
Thanks to the advise of Buso, i made this change which seems to work and give you 1 (ONE) extra level or sub-folders.

Have struggled add more levels, but this is all i need.

So anyway, goto system/libraries/Router.php, goto line 211 (just below // Set the directory and remove it from the segment array) and insert this code

Code:
if(is_dir(APPPATH.'controllers/'.$segments[0].'/'.$segments[1])){
                $this->set_directory($segments[0].'/'.$segments[1]);
                $segments = array_slice($segments, 2);
            }else{
                $this->set_directory($segments[0]);
                $segments = array_slice($segments, 1);
            }

instead of this code

Code:
$this->set_directory($segments[0]);
                $segments = array_slice($segments, 1);

hope this helps someone!




Theme © iAndrew 2016 - Forum software by © MyBB