Welcome Guest, Not a member yet? Register   Sign In
Are Multiple Sub-folders for Controllers Allowed?
#13

[eluser]riwakawd[/eluser]
[quote author="DavidZB" date="1232175221"]I found a way to allow more than one or two subfolders in the controllers folder. It was easy, and allows all of the normal functionality, even the method's params.... But i had to doit on the very same Router.php library.... anyway, if you want, is better to save a copy from your original Router.php class before testing this code.... here it goes:

In CodeIgniter 1.7.0, in the Router.php library, in the
Code:
_validate_request($segments)
function around line 205-207 there's the next code:

Code:
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);

Just after that code, insert the next lines:

Code:
//----------- NEW CODE ------------

while(is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]) && count($segments) > 0){

    // Set the directory and remove it from the segment array
    $this->set_directory($this->directory . $segments[0]);
    $segments = array_slice($segments, 1);
}

//----------- END OF NEW CODE ------------

so at the end, it should look like this:

Code:
// Set the directory and remove it from the segment array
$this->set_directory($segments[0]);
$segments = array_slice($segments, 1);

//----------- NEW CODE ------------

while(is_dir(APPPATH.'controllers/'.$this->directory.$segments[0]) && count($segments) > 0){

    // Set the directory and remove it from the segment array
    $this->set_directory($this->directory . $segments[0]);
    $segments = array_slice($segments, 1);
}

//----------- END OF NEW CODE ------------

After this, everything is just normal. Save and test. You'll find this very usefull (it was for me). I hope this functionality to be inside the next CodeIgniter's version, jeje.

PD1: Sorry about my english. It isn't my natal language.
PD2: If this thread is already closed, it doesn't matter. I found this thread; someone else will find it too.[/quote]

Just seeing if you have new code for current codeigniter will it pick up it for default controller.


Messages In This Thread
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-17-2008, 11:31 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-21-2008, 12:12 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-21-2008, 12:20 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-21-2008, 12:22 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-21-2008, 07:21 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-22-2008, 05:51 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 07-30-2008, 04:27 AM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 01-16-2009, 11:53 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 03-25-2009, 10:13 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 12-04-2010, 11:44 PM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 05-26-2011, 01:46 AM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 10-26-2012, 12:14 AM
Are Multiple Sub-folders for Controllers Allowed? - by El Forum - 04-21-2014, 10:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB