Sub Folder Problem |
Hi,
I started to develop CMS system and it will have 2 subfolder like, admin and interface. Interface will store frontend controllers and I will use admin as management controller. The problem is when i change default route like $route['default_controller'] = "interface/className/methodName"; But I got 404 error. Class and method name are correct even I check capital letters. ![]() resim gönder (02-05-2015, 04:20 AM)kazimkaragul Wrote: Hi, What I do and you can do is create a main controller (put in the application/core folder) that extends the CI_Controller like so: PHP Code: class MY_Controller extends CI_Controller { Then you can create two controllers that will be put into the application/libraries folder that will extend you main application controller (MY_Controller.php). I call mine Admin_Controller.php and Frontend_Controller.php: PHP Code: /* application/libraries/Admin_Controller.php */ And finally for your controllers that are for the "admin area", they will extend the Admin_Controller. Your urls will look like : http://example.com/admin/blog/edit/1 Also to make this all work you will need to put the following autoload function from (I believe) Phil Sturgeon at the top of your application/config/config.php file to tell Codeigniter to autoload the Admin or Frontend Controller depending on what is being "extended" PHP Code: function __autoload($classname) { Also update your application/config/routes.php file accordingly. So if your main admin page/controller is the dashboard controller & index function insert PHP Code: // set your default controller to the main controller that will extend your frontend controller and add: I hope this helped and I didn't confuse you or talk in circles too much.
Phil was putting the Base Controllers in the /core dir, which makes more sense. They're controllers, NOT libraries.
See how Phil was doing it: https://philsturgeon.uk/blog/2010/02/Cod...ng-it-DRY/ It loads from the /core dir. If you still want it to be able to autoload libraries, you could first see if the file exists in /core, and if not check /libraries.
default_controller doesn't accept directories, only controller and method names.
(02-05-2015, 09:23 AM)egall8 Wrote:(02-05-2015, 04:20 AM)kazimkaragul Wrote: Hi, Thank you for answer but I just want to create subfolder. I am trying to create a kind of HMVC structure.
|
Welcome Guest, Not a member yet? Register Sign In |