![]() |
ci-3 how to create admin without duplicating core files - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: ci-3 how to create admin without duplicating core files (/showthread.php?tid=65569) Pages:
1
2
|
ci-3 how to create admin without duplicating core files - siva - 06-26-2016 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, RE: ci-3 how to create admin without duplicating core files - skunkbad - 06-26-2016 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. RE: ci-3 how to create admin without duplicating core files - siva - 06-27-2016 (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??? RE: ci-3 how to create admin without duplicating core files - Fallebdi - 06-27-2016 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/ RE: ci-3 how to create admin without duplicating core files - InsiteFX - 06-27-2016 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. RE: ci-3 how to create admin without duplicating core files - Ivo Miranda - 06-27-2016 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/ RE: ci-3 how to create admin without duplicating core files - siva - 06-27-2016 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]. RE: ci-3 how to create admin without duplicating core files - Ivo Miranda - 06-27-2016 (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. 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. RE: ci-3 how to create admin without duplicating core files - InsiteFX - 06-27-2016 If you want to keep the application as one the the directory structure would be like this: Code: application RE: ci-3 how to create admin without duplicating core files - Shawn - 07-10-2016 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 |