CodeIgniter Forums
Does CI's route support two levels sub-folder ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Does CI's route support two levels sub-folder ? (/showthread.php?tid=4469)



Does CI's route support two levels sub-folder ? - El Forum - 11-27-2007

[eluser]Wades[/eluser]
Hi, here is my problem. I have file structure like this
Code:
|--application
  |--controllers
     |--admin
        |--user
           |--test.php

in test.php
Code:
<?php
class Test extends Controller {

    function Test()
    {
        parent::Controller();
    }
    
    function myfunction()
    {
        echo 'myfunctio here';
    }
}
?>

but I can't access it through the url like :
Code:
http://localhost/admin/user/test/myfunction
I get the 404 error

any help is appreciated!


Does CI's route support two levels sub-folder ? - El Forum - 11-27-2007

[eluser]gtech[/eluser]
Hi I searched the forums for you and I tried what you were doing and it doesn't work, CI only supports one level of subfolder for controllers.

however someone else had this problem so I would recommend reading the following thread.

[url="http://ellislab.com/forums/viewthread/56100/"](CLICK HERE FOR THREAD)[/url]

[edit]
I am running php5 so all I had to do to get it working is copy the code in the 1st post from the link above and create a file:

......\system\application\libraries\MY_Router.php

and then renamed peters class to MY_Router and it worked a treat! I could have unlimited subdirectories for controllers Smile
Code:
class MY_Router extends CI_Router {



Does CI's route support two levels sub-folder ? - El Forum - 11-27-2007

[eluser]Wades[/eluser]
Wow. Gtech, You are so kindhearted, Thanks a million!!!


Does CI's route support two levels sub-folder ? - El Forum - 11-27-2007

[eluser]gtech[/eluser]
no probs, hope it worked.

[edit]
somebody else asked this same question today and a reply was to look at matchbox (the new name for modular separation), just search the forums. I havn't looked at it yet, but may also be a good read as it looks as thought its another solution for organizing code.