Specifying routes for separate applications |
[eluser]jwburnside[/eluser]
I accidentally posted this in the wiki portion of the forum, sorry if it looks like a re-post: I’ve been trying to get this figure out for quite a while now, but I have yet to derive out a solution. I have one CI core that supports many applications. The directory structure looks like this: - applications - controllers - admin - controller files… - catalog - controller files… - evaluations - controller files… - linkreport - controller files… - etc. All I am trying to do is specify a route so that if only the folder name is used in the url, it will default to the controller I have selected. For instance: http://www.mysite.com/admin instead of http://www.mysite.com/admin/controller_name Any ideas? I have looked over the routes user guide, but entries such as this don’t seem to work: $route[‘admin’] = “admin/controller_name”; Does routing like this not apply to folders?
[eluser]pickupman[/eluser]
You need to stack them, and they try in order from first listed to last. It quits when it finds the first match. I have something very similar. I have files more modular, so if I need to copy a front/back end controller to a new app the admin controller goes with it. I have -application -controllers -admin -admin.php (Default dashboard) -catalog -catalog.php -admin_catalog.php -evaluations -evaluations.php -admin_evaluations.php Try: Code: /* Admin routes */
[eluser]toopay[/eluser]
If you are not doing some fancy stuff, why you didnt put any of your controller at 'admin' folder into a single file. In that way, you can access it like : Code: http://yoursite.com/admin (for index function)
[eluser]pickupman[/eluser]
[quote author="toopay" date="1305411230"]If you are not doing some fancy stuff, why you didnt put any of your controller at 'admin' folder into a single file. In that way, you can access it like : Code: http://yoursite.com/admin (for index function) That only works until you actually have a real application and several modules. Also by breaking them makes is easier to maintain and reuse for another project. If you keep only a single admin controller it becomes pretty difficult to keep everything organized for crud for each type of controller.
[eluser]toopay[/eluser]
[quote author="pickupman" date="1305413143"]Also by breaking them makes is easier to maintain and reuse for another project.[/quote] I think everybody has already know such basic benefits of HMVC. But i try to understand what he/she really mean or want to achieve, by his/her approach, not mine. You already have give some modular suggestion at your first post, so in addition suggestion, i think maybe for now, he just only need a simple one.
[eluser]jwburnside[/eluser]
Hey thanks for the replies. As it turns out, the fix was in our .htaccess files, since we configured each one on an application by application basis. I think perhaps the RewriteBase statement may have been conflicting with the entries I put in Routes. If I had more time I would research this and post a more definitive answer, but for now I put an index fix in there and it works fine: DirectoryIndex index.php/admin/controller_name |
Welcome Guest, Not a member yet? Register Sign In |