Welcome Guest, Not a member yet? Register   Sign In
Does CI's route support two levels sub-folder ?
#1

[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!
#2

[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 {
#3

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB