O'Reilly logo

Professional CodeIgniter® by Thomas Myer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6.3. Creating a Rudimentary Admin Framework

One of the great things about CodeIgniter controllers is that they can be organized into folders. This adds only one more URI segment to your activity but keeps related controllers together. In the following sections, you build out some administrative controllers related to orders, products, categories, and admin users, all of which reside in a folder called admin.

This way, once a user logs in, he will be directed to work in the admin/products controller or the admin/categories controller (depending on his task), and each set of controller tasks can be kept separate and organized.

The best thing about this arrangement is that you can continue to work with the same models as before, extending them as needed (although you'll find that many of the models you wrote for the public side of the site are just as useful in the admin context).

The first step in working up a series of admin controllers is to organize your work into folders and controllers, followed by thinking about an administrative framework you can employ. This framework needs to be fairly secure and should involve a new model and database table (for users) and a login form and verification process that sets some kind of global variable needed to access the admin controllers and views.

Before you get too involved with all that, it's time to organize your admin controllers.

6.3.1. Using Folders to Organize Controllers

When you're building a more complex series of interrelated ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required