![]() |
building an efficient admin control panel - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: building an efficient admin control panel (/showthread.php?tid=4600) |
building an efficient admin control panel - El Forum - 12-05-2007 [eluser]A.M.F[/eluser] hello guys, i am working in those days on an admin control panel, and i want to hear some tips from u, and to see what do u think about it, and how efficient is it. so... i have two controllores: one is an "admin" controlloer. in there i control on the page and directing the user to the wanted admin pages. +the login validating is also in there. the second controller is called "Execute". in there i am actually making all the actions. this controller is checking the forms and validating them, and working with the data from them. those controlloers are in the same directory with all the other controllers. now the views files. i have a different directory for the admin view files, and for each page i have a different view file. i have zero models, helpers or librarys for the admin control panel. so guys.. what do u think? what is ur suggestions? how can i make it better? building an efficient admin control panel - El Forum - 12-05-2007 [eluser]Michael Wales[/eluser] If it works for you - go for it. Personally, I usually manage my apps in the following way: 1. Establish MY_Controller.php to create a Public_Controller and Admin_Controller class. These are used to determine whether the user needs to be logged in or not, as well as other various functions. 2. Create a controller admin that extends Admin_Controller - this handles very generic administrative functions. 3. Create a controller named admin_pages which houses all of the methods for page administration - this is what I like to call a child-admin method. We would have things like view, create, edit, delete in here. 4. Setup the following routing rules: Code: $route['admin/([a-z]+)/([a-z]+)/([a-zA-Z0-9_-]+)'] = "admin_$1/$2/$3"; 5. I create a directory /views/admin/ which houses directories for each of my admin_* classes. For example: /views/admin/pages/create.php would be the path to the view that is loaded by the admin_pages->create() method. building an efficient admin control panel - El Forum - 12-05-2007 [eluser]sandwormusmc[/eluser] For a past project, we used debug_backtrace in a library called MyAuth to check the function the user was calling, and separate database tables to assign each function name to a role id, then assigned that role per user. IMO this was a pretty flexible and allowed for addition of new functions, roles, etc. If you're interested, let me know and I can post some sample code. building an efficient admin control panel - El Forum - 12-05-2007 [eluser]A.M.F[/eluser] walesmd - thx for the tips. i'll try to make something like what u wrote but here are some questions: 1. admin_pages controller is actually executes all the actions? 2. "Create a controller admin that extends Admin_Controller - this handles very generic administrative functions" - generic functions? what do u mean? thank u. sandwormusmc - it sounds interesting. can u add some more detailes about the way u work? building an efficient admin control panel - El Forum - 12-06-2007 [eluser]A.M.F[/eluser] guys..? building an efficient admin control panel - El Forum - 12-06-2007 [eluser]Sarfaraz Momin[/eluser] WHat walesmd meant to say is that the Admin_controller would check weather the user is logged in as the siteadmin so he can be redirected to the control panel. In short it takes care of the AUTH of the admin panel. This is very generic admin task to keep the user validated till he has not logged off. Also there can be anything you want to do like keep a track of what the siteadmin has done changes or so. These are what is meant by generic admin task. Hope that makes sense. Good Day !!! building an efficient admin control panel - El Forum - 12-06-2007 [eluser]A.M.F[/eluser] thx Sarfaraz Momin, now i get it. so u actually have a hirerchy that looks like that: admin_control that handels that login -->> admin controller that redirects you to the wanted pages -->> admin controller (admin_pagees) that makes all the actions. is that right? - and what about debuging hlpers? what kind of bugs are you checking? the only bugs that i am checking in a helper, is to see if the query has results for the page, and to see if the page number in the pagination is valid. building an efficient admin control panel - El Forum - 12-06-2007 [eluser]Michael Wales[/eluser] MY_Controller.php Code: class Admin_Controller extends Controller { admin.php Code: class Admin extends Admin_Controller { admin_pages.php Code: class Admin_pages extends Admin_controller { Note: If you copy-paste that code and complain it doesn't work I swear... building an efficient admin control panel - El Forum - 12-06-2007 [eluser]A.M.F[/eluser] wals - i tried to copy paste it to see if it works, but i keep getting the same error! :bug: just kidding lol.. ur last setence made me smile. any way... i think now i understand it more, and if u don't mind i might use it on my next works - i'm sure it will spice 'em up. but there is one thing i don't get: in the admin_pages.php u call a model: Code: $this->load->model('pages_m'); why do u call this model? besides, i steal didn't get the whole idea of models :down: (and yes, i red the user guide) building an efficient admin control panel - El Forum - 12-06-2007 [eluser]Michael Wales[/eluser] I only called that model based on principle, probably because you would be using it in that controller. The Admin_pages controller is the controller used to, obviously, administer pages. The pages_m model contains all of our methods that interact with the database. By loading this model within the constructor you save yourself some typing later on. For instance, if we had a create() method, which created a new page: Code: function create() { In pages_m->createPage I would futher validate my data, ensuring I am only inserting columns I am expecting from this particular form, and then make the database insert. I guess I strayed from the point - the reason it's there is because you're probably going to use it in every method within this controller. ![]() |