Multi Level controller not working |
[eluser]jaswinder_rana[/eluser]
My structure for my controller is application/controllers/admincp/config/countries.php It's not working when I try to access it like http://localhost/index.php/admincp/config/countries. I am getting 404 message. If I copy that same file and put it in admincp folder (application/controllers/admincp/countries.php), it works. So my syntax is correct but it's not letting me put controller in snd level. Am I doing something wrong? Thanks
[eluser]jaswinder_rana[/eluser]
Just checked in system/libraries/Router.php and it only allows 1 folder in controllers. Is there a way to over come that? My_router.php????
[eluser]jaswinder_rana[/eluser]
Not sure if it's correct but following did it Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
[eluser]Michael Wales[/eluser]
Don't use subfolders to manipulate the URI - that is what routing is for.
[eluser]jaswinder_rana[/eluser]
So, just change URLs and create routing rules? I also wanted to do it so I could organize different controller logically. I din't want all of them in one folder and wanted to organize them; besides routing (but din't know I could write routing rules either ).
[eluser]Michael Wales[/eluser]
You can still organize them better (into a single subfolder level). With CodeIgniter there is a difference between filesystem organization and URI organization. You can literally make your URIs anything you want while still maintaining a good backend file organization. Code: $route['omasdofmasdfniasdkfnasiodasdf'] = 'home';
[eluser]jaswinder_rana[/eluser]
Sorry, I din't understand. So, I can still keep my sub-folders like conrollers/admincp/config/countries and then write a rule in route config file? What will it look like? I did read the documentation but I am not sure (yet) how to do it. will it be ?? Code: $route['config/countries'] = 'admincp/config/countries'; Thanks
[eluser]Michael Wales[/eluser]
Try it - I promise, you won't break anything.
[eluser]jaswinder_rana[/eluser]
I just tried it with 2 different structures 1) controllers/admincp/config/countries Code: //Tested with http://localhost/index.php/admincp/config/countries 2) controllers/admincp/countries Code: //Tested with http://localhost/index.php/admincp/config/countries But, I was hoping to keep structure like 1) and still be able to make it work. It's not working as I have sub-sub-level. Sorry for being dumb but I can't make it work EDIT: I am assuming routes.php is for URI management and not for folder, hence won't work for me??
[eluser]Michael Wales[/eluser]
You can only go one-level deep on controllers, like we mentioned before. Code: ./controllers I'm sure if you did some searching around the forums you could find a solution for this though, I have seen it occur numerous times. |
Welcome Guest, Not a member yet? Register Sign In |