Welcome Guest, Not a member yet? Register   Sign In
admin panel: not sure whether create controller for each page or use methods
#1

[eluser]lolmann[/eluser]
hey,

i'm creating an admin panel which has the pages x,y,z. i set up a controller called administration.php which handles the user authentication and serves the views. i started out thinking that each of the pages x,y, and z will have their own method in the controller.

but now i realize that each of these pages will actually have quite a lot of code in them. additionally, for some pages it would be great to have methods in them. for example, on an admin page where there is a form it would be great to have a method which processes the form input.

i therefore think it would be great if each of the pages x,y, and z had their own controller.

but how do i give them their own controller if administration.php is the controller already?

do i call a controller from within a controller? am i missing something?

i appreciate you help.

thanks-

l
#2

[eluser]Phil Sturgeon[/eluser]
I wrote an article explaining various ways of doing this.
#3

[eluser]lolmann[/eluser]
[quote author="Phil Sturgeon" date="1281120693"]I wrote an article explaining various ways of doing this.[/quote]

Thanks Phil. I've read your article before asking my question. There is a lot of useful information in there but my question is not answered.

I chose what you call method #2.

Now I'm not sure how to be able to use distinct controllers for each page in the admin panel.

I think my question is not limited to the creation of admin areas. In a broader sense you could say that I want to know how to give pages of a website the powers of a controller. Or how to actually have them have their own controller each but still have them called under a certain directory (in my case, "administration/").

Does this make any sense? If not, tell me and I'll try to re-explain.
#4

[eluser]Phil Sturgeon[/eluser]
You might want to try again. ;-)

I THINK what you are saying, is how do you make a controller part of the admin panel?

Take a look at my Base Controllers article, it might help you work it out.
#5

[eluser]lolmann[/eluser]
[quote author="Phil Sturgeon" date="1281122966"]
Take a look at my Base Controllers article, it might help you work it out.[/quote]
This looks good. I'll look into it. Thank you.
#6

[eluser]eokorie[/eluser]
Hi Phil,

I am actually trying to apply Method #3 of your admin panel setup in a project I have coming up. I cant seem to get the url structure to come up as admin/modulename where as module/admin seems to work fine. I have added the routes in the application main config file. Do I need to to anything else to get admin/modulename?

Thanks
#7

[eluser]pickupman[/eluser]
I am fan of the base controllers as well. I created routes to do what you wanting to do
Code:
$route['admin/([a-zA-Z_-]+)/(:any)'] = '$1/admin_$1/$2';
$route['admin/([a-zA-Z_-]+)'] = '$1/admin_$1/index';
$route['admin/(:any)']        = 'admin/$1';
$route['admin']               = 'admin/index';

This allows me to have controllers like pages.php and admin_pages.php. I am using Phil's Modular Separation as well so these are in modules. All of my front end stuff is in pages.php. The admin dashboard has a link to /admin/pages and it will load admin_pages.php controller. The last 2 rules are for creating an admin dashboard. I have a admin.php controller with a simple index method. This controller basically displays your typical dashboard stuff with links to the other various admin_something.php controllers in the header of the page.

Using base controllers allows all of the admin_something.php controllers to all be able to check admin rights in one construct.




Theme © iAndrew 2016 - Forum software by © MyBB