Step 1 – Create an admin area in CodeIgniter 3

(You may be under the wrong impression that this is the first lesson in creating a CMS using CodeIgniter 3. Actually, this continues a previous series: http://avenir.ro/codeigniter-tutorials/. You can find out more about the prerequisites here: http://avenir.ro/create-cms-using-codeigniter-3/)

Every respectable blog must have an admin area. In CodeIgniter there are a lot of methods to create such an area. In this tutorial we will simply make a directory named admin inside the controllers directory and also an admin directory inside the views directory.

So let’s get to work

First of all we create create the directories mentioned before.

Now we will create a controller named Dashboard (Dashboard.php)inside the application/controllers/admin directory:

As you can see, the index() method of the dashboard class will load dashboard_view which is loaded from the views/admin directory. For starters the dashboard_view.php will look like this:

After we’ve done all this, we must make sure that when someone goes to http://localhost/admin, he/she will be taken to the dashboard. To do this we simply add a route inside the routes.php file. Now, the file will look like this:

Also, one thing to note is that the Dashboard is extending Admin_Controller. In this tutorial I decided to follow Jim Parry’s example in creating more than one single MY_Controller. So, MY_Controller.php will look like this for now:

That’s it. We now have an admin area. In the next tutorial we will create the basic template for the dashboard’s pages and after that we will secure the dashboard.

0 thoughts on “Step 1 – Create an admin area in CodeIgniter 3

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.