Welcome Guest, Not a member yet? Register   Sign In
ci-3 how to create admin without duplicating core files
#1

i want to create admin panel without duplicating core files...i have found three methods

1.hmvc
2.separate applications
3.running multiple app with one codeigniter --from user guide

which one is best??
please advice/help me,
Reply
#2

None of the above. You're going to need to authenticate your admin, so what difference does it make if it's in the same application as your other users? Just authenticate. Keep it simple.
Reply
#3

(06-26-2016, 11:50 PM)skunkbad Wrote: None of the above. You're going to need to authenticate your admin, so what difference does it make if it's in the same application as your other users? Just authenticate. Keep it simple.

could you please explain???
Reply
#4

if admin logged in , redirect him to his views , depend on your authentication.

you can follow other structure for clarity .make separate folders for each one into controller .
application/
views/
admin/
users/
public/
controller/
admin/
users/
public/
models/
admin/
users/
public/
Reply
#5

Because when a user login to your website you need to authenticate them, which means you need a authentication system to log them in.

If it's an admin login then you redirect them to your admin dashboard.

In controllers views etc; Just create an admin folder in each for the admin files.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

What do you mean by: "Without duplicating core files?". A simple example would help.

As the other answers above suggest you will need an authentication system. I would recommend:
http://benedmunds.com/ion_auth/
Reply
#7

thanks for the reply [ @InsiteFX @Ivo Miranda @skunkbad Wrote] ... i mean if i enter www.example.com/admin, it should go to admin login page,so how will be the directory structure? which means separate front-end and back-end.

ex:
if its user side :
/application

admin:
/application/admin [here all the admin files].
Reply
#8

(06-27-2016, 05:39 AM)siva Wrote: thanks for the reply [ @InsiteFX @Ivo Miranda @skunkbad Wrote] ... i mean if i enter www.example.com/admin,  it should go to admin login page,so how will be the directory structure? which means separate front-end and back-end.

ex:
if its user side :
/application

admin:
/application/admin [here all the admin files].

Is this your first CI app? You have several options but I will give you an easy example:
1) /application/controllers/Admin.php would be your controller and you will be able to access it by default by example.com/admin
2) In this Admin.php controller you should have all the methods, like login, register, and so on... You might want to keep some core functionality in a library rather then putting all of it in the controller but that is up to you.
3) If you want to use a controller for the frontend you can just you a default controller in the config and access it in example.com. That controller should contain all logic for the user that is not an admin.

Is this what you were looking for? I strongly recommend you to do the Code Igniter tutorial and read all the documentation. It's possibly one of the easiest documentation I have ever read in my life and the tutorial is also pretty useful.

Please take into consideration that building an authentication system is something really hard to do. I would recommend to use a third party library such as Ion Auth.
Reply
#9

If you want to keep the application as one the the directory structure would be like this:

Code:
application
---- controllers
---- ---- admin
---- views
---- ---- admin

public or public_html
---- assets
---- ---- admin
---- ---- ---- css etc;
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

I found the following controller hierarchy useful:
The base controller (called MY_Controller and extends CI_Controller) does not check for login: any controller that extends it is open to the public.
The user_controller extends the base controller and checks that the user is logged_in. Any controller that extends it is only available to logged in users.
The admin_controller extends the user_controller and checks for the admin role. Any controller that extends it is available only to admin users.
All 3 controllers reside inside the core/MY_Controller.php file
Reply




Theme © iAndrew 2016 - Forum software by © MyBB