Codeigniter 3 RC2 Admin developement guideline - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17) +--- Thread: Codeigniter 3 RC2 Admin developement guideline (/showthread.php?tid=1253) |
Codeigniter 3 RC2 Admin developement guideline - summer - 02-23-2015 Hi there everyone. I'm developing an html/css admin template with Codeigniter 3 RC2 to use as back-end of my sites. i want to develop it in way that i can use it with multiple sites. each of my site contains front-end and back-end. which share the same database and config file, everything else i keep separate. i have a little issue, i need some expert advice on how to setup admin to work correctly. all my links open at: Code: www.domain.com/manager/{page_name} thats why i have one controller manager, but i want {page_name} (login, dashboard, orders) to be my controller, can is do this with codeigniter's MVC structure or do i need HMVC for that. if HMVC is required where can i get one which will work with CI 3 RC2. Thanks. RE: Codeigniter 3 RC2 Admin developement guideline - silentium - 02-23-2015 You can add folders in the controllers folder. In your case, create a folder called "manager" in the controllers folder. Then, in the manager folder you create a controller for each page you want. The path would now be www.domain.com/{folder}/{controller}/{function}, for example www.domain.com/manager/user/create Hope that helps. RE: Codeigniter 3 RC2 Admin developement guideline - summer - 02-24-2015 Hi Silentium! Thanks for the reply, problem is almost solved. how can i set routes for it so that next segment after "manager/" is a controller in manager(sub-directory in application/controllers). it this right? Code: $route['manager/(:any)'] = 'manager/$1'; how can i set the default controller for this sub-directory(manager)? Thanks in advance. RE: Codeigniter 3 RC2 Admin developement guideline - InsiteFX - 02-24-2015 /(:any) is a catch all route and needs to be the very last route in your routes file or none of the routes after it will work! HMVC for CI 3.0 RE: Codeigniter 3 RC2 Admin developement guideline - summer - 02-24-2015 ^Thanks for the routing tip, i have that HMVC but its not optimized for RC2, at least not yet. has some issues with autoloading session library. another question: I have some functions in each controller which are same for all. how can i make a common file for it and reuse in all admin controllers. Thanks. RE: Codeigniter 3 RC2 Admin developement guideline - InsiteFX - 02-24-2015 Createe a MY_Controller and put all your common controller functions/methods in it. RE: Codeigniter 3 RC2 Admin developement guideline - summer - 02-24-2015 ^Thanks alot, i have already done that. will i be able to move to hmvc after using MY_Controller? RE: Codeigniter 3 RC2 Admin developement guideline - silentium - 02-24-2015 (02-24-2015, 01:56 AM)summer Wrote: ... There is no need to add anything to the routes config. CI supports sub folders in the controller directory by default. Here is the documentation link http://www.codeigniter.com/userguide3/general/controllers.html#organizing-your-controllers-into-sub-directories. The only optional settings you might need is setting a default controller for the sub-directory. To do that, just add what you have on row 2 in the routes.php config. Code: $route['manager'] = 'manager/<default_controller>'; Regarding shared functions, I would go with a 'MY_Controller' as recommended by @InsiteFX More info on how you do that can be found here http://www.codeigniter.com/userguide3/general/core_classes.html RE: Codeigniter 3 RC2 Admin developement guideline - summer - 02-25-2015 ^Thanks everyone for the help. RE: Codeigniter 3 RC2 Admin developement guideline - InsiteFX - 02-25-2015 Yes, Your MY_Controller will extend the MX_Controller for HMVC. |