Welcome Guest, Not a member yet? Register   Sign In
CMS best practice on CI
#13

[eluser]Mr. Pickle[/eluser]
The Admin_controller like I set it up in my previous post is not a controller as in that it is being called via an url.

It is just a class with overall functions that the 'normal' controllers (the ones that are accessed via an url) use.
You will store all your overall admin functions (like checking of someone is logged in, do the logout, etc.) in this Admin_Controller. You can still keep your controllers/admin.php controller, for example to view the login page at /admin/login/ (where admin is a controller and login the method)
Rerouting always take place before the rest, so you can have admin paths (like /admin/login) that actually load admin as a controller and login as a method, as also have admin paths that are rerouted, like /admin/news/add ==> /news/add.

To explain a little the advantages the Admin_controller can give you:
If you for check on construct of the Admin_controller if a user is logged in, you just extend the Admin_controller at every controller that is part of your admin-system and the check if someone is logged in will automatically take place.

Code:
<?php
class Admin_Controller extends CI_Controller
{
    public function __construct()
    {
       parent::__construct();
       if( !$this->is_logged_in() )
       {
           redirect('path-to-login-page'); // where you replace this with the path to your login page
       }
    }

    public function is_logged_in()
    {
        // here the code to dermine if the user is logged in
    }
}
?>


Messages In This Thread
CMS best practice on CI - by El Forum - 10-22-2012, 05:23 AM
CMS best practice on CI - by El Forum - 10-22-2012, 05:41 AM
CMS best practice on CI - by El Forum - 10-22-2012, 05:48 AM
CMS best practice on CI - by El Forum - 10-22-2012, 05:56 AM
CMS best practice on CI - by El Forum - 10-22-2012, 05:57 AM
CMS best practice on CI - by El Forum - 10-22-2012, 05:58 AM
CMS best practice on CI - by El Forum - 10-22-2012, 06:58 AM
CMS best practice on CI - by El Forum - 10-22-2012, 07:06 AM
CMS best practice on CI - by El Forum - 10-22-2012, 07:15 AM
CMS best practice on CI - by El Forum - 10-22-2012, 09:24 AM
CMS best practice on CI - by El Forum - 10-23-2012, 02:31 AM
CMS best practice on CI - by El Forum - 10-23-2012, 04:08 AM
CMS best practice on CI - by El Forum - 10-23-2012, 04:49 AM
CMS best practice on CI - by El Forum - 10-23-2012, 04:55 AM
CMS best practice on CI - by El Forum - 10-23-2012, 05:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB