1. Modern
  2. Light
  3. LightGray
  4. Gray
  5. White

 A post with Image

gumdepartmentstore

Establishing our needs

When developing the new version of The Authentication Library – I needed a way to easily create an admin panel. What I needed was a simple convention that I could use to build the interface. Some of the things I needed were:
Easily create the admin panel.
Be able to manage the panel easily.
The front-end and back-end files needed to be in sensible places, so I know where to edit things.
I could not use two applications. Ever hear of a CodeIgniter library that makes you use two applications?
I couldn’t use a 3rd part library. It just couldn’t work.

In this article, I’ll explain the conventions and methods I used to get this easily. You can use this exactly as it is here in your own applications, or change it around as you like, or totally dis-regard it. It’s the way I did things for The Authentication Library so might be useful for developers who want to build applications around The Authentication Library.
Front-end Files

It seems logical for the front-end files to be located at the base of application/controllers/ so that’s where they’ll go. These models should be the singular of the object it is you’re developing. Examples would be Page, User, and Video. This also makes sense for the URLs. Let’s take Page as an example. The URL would be index.php/page/home which looks right for a page URL, and users would be like this: index.php/user/admin. Obviously these URLs would also require some custom routes, but this would be different for each class.
Back-end (admin) Files

Now we know where the front-end files are going to be, we can decide where the admin files are going to go. I chose to put them all in a subfolder: application/controllers/admin/. These files should be named the plural of the front-end file. To take the examples from before, they’d now be Pages, Users and Videos. This makes sense now because the URLs will be index.php/admin/users/manage. One thing to note is that not there will be 4 segments of the URL. So when passing an ID for a page (example) the URL will be index.php/admin/page/edit/1.
Including Models

Firstly, the “include” I’m talking about isn’t the PHP include() – that comes next. I haven’t yet implemented this in The Authentication Library – this is being added in for the next major release.

Models will require a naming convention for this system to work. We can’t use the singular or plural of the object (Page or Pages) because if we do in one of the cases (front-end or back-end) will throw a fatal error “Cannot redeclare class”. So the way I’m going to do things is to name the model the singular (page, user, video) with model on the end. So our model files will be usermodel.php, pagemodel.php and videomodel.php. Now we can load the model automatically by using an extended Controller.
Automatically Loading Models

Posted by: on May 25th, 2009
In: Uncategorized
Having: No Comments