Again. Controller in Sub-folders (new way?) |
[eluser]Ignacio[/eluser]
I'm testing this on 1.5.4 routes.php: Code: $route['default_controller'] = "main/main"; folders: Code: application/controllers/main/main.php views: Code: application/views/main/main.php application/controllers/privacy/privacy.php: Code: <?php Ok... there's all my code, and works fine using this: Code: site.com Yes! Great, works like I want... BUT! look again my routes file..., and imagine 500 pages on my site..., I can't write routes pages by pages, I need an automatic router. I use http://code.google.com/p/enginemvc/ for a while, but is very small, I need something like CI, but don't have the features like I want. I need some help with this issue. Thanks!
[eluser]tonanbarbarian[/eluser]
Have you tried this without the routes... because the loader will search in a single depth sub folder for a matching controller The only time we have found an issue is if you want more than 1 sub folder depth Code: application/controllers/main/admin/admin.php Or if you try to do something tricky like Code: application/controllers/main.php but just to have Code: application/controllers/main/main.php It is also unclear from your example why you are putting the controllers into sub folders. I assume there are going to be multiple controllers under the main sub folder and also under the privacy subfolder. If not then just do not use subfolders.
[eluser]Ignacio[/eluser]
First of all, BIG thanks for your response tonanbarbarian. You right, I don't need controllers in folder, in fact I don't use them in folders in my others MVC system, hehehe. just: Code: application/controllers/main.php Works fine now with just that. Maybe I wil need a solution in a few days for doing something like this: Code: application/controllers/admin/main.php Or start doing something like this too is fine: Code: application/controllers/admin/main.php I don't like the modular separation for now. And yes, this data was just examples, I'm making a strong base for doing a social web site, that need a lot of files, folders and that kind of stuff. Thanks again pal, sorry about my poor english, I'm from Argentina. Thanks.
[eluser]tonanbarbarian[/eluser]
Both of the last 2 example you give should be possible without any modification or routes
[eluser]Ignacio[/eluser]
I know, but I don't want URL like this: site.com/public/privacy, maybe with .htaccess I can fix that, URL for the admin site.com/admin/privacy is fine.
[eluser]tonanbarbarian[/eluser]
so then do not put any of your public controller in a subfolder do something like the following Code: application/controllers/admin/main.php I do this all the time. Usually the only sub folder I have in the controllers is an admin sub folder that contains admin versions of all of the root controllers
[eluser]Ignacio[/eluser]
yes, is a good solution, thanks, I'm working exactly like that now, thanks again. |
Welcome Guest, Not a member yet? Register Sign In |