codeigniter doesn’t look into the sub-directory, if we have controller with the same name in the directory |
[eluser]Unknown[/eluser]
If we have structure if the “controllers” folder like this: about.php /about/employees.php Link “/about/” works fine, but link “/about/employees/” does not. How do I create a logical structure then? # about.php <?php class About extends Controller { function index() { echo 'in About'; } } #about/employees.php <?php class Employees extends Controller { function index() { echo 'in Employees'; } } Can you help me?
[eluser]tomcode[/eluser]
In Your case CI is looking for the method employees in the controller about. What You can do : folder structure : - controllers -- about --- default_controller.php --- employees.php The default_controller.php is what You have set in Your config/routes.php as default. It takes all about/ requests and the employees controller takes the about/employees requests. You may solve Your problem also using routes, but that's not my thing.
[eluser]Colin Williams[/eluser]
I simply avoid nesting controllers. If you structure your MVC RESTfully, which I think you should, then you have one controller per resource. I don't see how nesting would come up. Having said that, CI could probably be better about handling subfolders. At the very least, seeing about/employees, CI should figure out, "About controller exists. Employees method doesn't exist. Employees controller exists in /about/ folder. Call Employees::index()" I think I've seen people do this with their own MY_Loader class before. Might want to hunt around for it.
[eluser]colorfingers[/eluser]
I'm having another issue with routing that I can't seem to get a grip on.... In my route.php I have set the default to 'site' which is in the root of the controller folder. If I perform 'http://localhost/codeigniter/' I get routed properly and the page displays. I have another controller, 'home', in the same directory. How do I access this controller? Setting the browser to 'http://localhost/codeigniter/home' results in a page not found error. Thanks, Bob ?;O)
[eluser]tomcode[/eluser]
What about http://localhost/codeigniter/index.php/home ? Do You read the User Guide ?
[eluser]colorfingers[/eluser]
Nevermind... Typo in the Home.php file... Thank you, Bob ?;O) |
Welcome Guest, Not a member yet? Register Sign In |