CodeIgniter Forums
How to create Admin Section in CodeIgniter Project? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Best Practices (https://forum.codeigniter.com/forum-12.html)
+--- Thread: How to create Admin Section in CodeIgniter Project? (/thread-67680.html)



How to create Admin Section in CodeIgniter Project? - Shivafeb17 - 03-23-2017

Hi all, 

I have created a simple project in CI. Now I want to create users and Admins. How to create an area only admin can login and modify data? Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?


RE: How to create Admin Section in CodeIgniter Project? - Wouter60 - 03-24-2017

Quote:Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?

I certainly wouldn't do that. You can create an admin controller, containing the functions for modifying data (in your database).
Make sure you have a login procedure that forces you to log in when you access the admin controller. Let the constructor of the admin controller check if you're logged in as admin or not.
You can develop your own authentication system, but you really don't need to. There are various authentication libraries for CI, like Ion_auth and Community_auth.


RE: How to create Admin Section in CodeIgniter Project? - InsiteFX - 03-24-2017

I just create an Admin Controller and view folders.

In all of the Admin Controllers do a check to make sure that the user is an Admin.


RE: How to create Admin Section in CodeIgniter Project? - CINewb - 06-21-2017

For anyone else wanting to do this, I believe you don't have to have a single admin controller.

You can just make a sub-directory inside "controllers" called "admin" and then place individual controllers in there.

For example:

\application\controllers\admin\Sales.php
\application\controllers\admin\Customers.php


RE: How to create Admin Section in CodeIgniter Project? - skunkbad - 06-21-2017

(03-24-2017, 02:06 AM)Wouter60 Wrote: You can develop your own authentication system, but you really don't need to. There are various authentication libraries for CI, like Ion_auth and Community_auth.

+1


RE: How to create Admin Section in CodeIgniter Project? - pb.sajjad - 06-21-2017

(03-23-2017, 10:21 PM)Shivafeb17 Wrote: Hi all, 

I have created a simple project in CI. Now I want to create users and Admins. How to create an area only admin can login and modify data? Should I create an ADMIN Folder in APPLICATION folder and install another CI in it?

Hi...
I think it's depends on you, your need and your project scale. With CI you could create an admin folder in controller and put your admin controllers in it, and for view, create an specific folder in views folder, if you want to have a different view for admin section. Another option is separate installation for main (users) and admin (you). In this case, you must consider that there are some common codes between these two apps installation that cause you do more and more copy/paste.

You decide about these...
Good Luck.


RE: How to create Admin Section in CodeIgniter Project? - ivantcholakov - 06-21-2017

For a relatively big project a separate admin application is more suitable. Copy/paste code could be avoided, but this means that you have to rework CodeIgniter for supporting shared code.

http://iridadesign.com/starter-public-edition-4/www/
http://iridadesign.com/starter-public-edition-4/www/admin