CodeIgniter Forums
Admin module - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Admin module (/thread-49525.html)

Pages: 1 2


Admin module - El Forum - 02-24-2012

[eluser]Mauricio de Abreu Antunes[/eluser]
Nunca usei, mas tem vários sites falando sobre e bem documentados.

I've never used but therer are several sites talking about it and with large documentation.


Admin module - El Forum - 02-24-2012

[eluser]Cálcio[/eluser]
Ok, I'll try found it later. I'm studying too Yii framework.


Admin module - El Forum - 02-24-2012

[eluser]pickupman[/eluser]
Codeigniter does not include any controllers, other than the simple "Hello world" welcome.php controller. An admin controller is probably used on any application, but how many would every been the same. My guess is zero.

You can make an admin controller as easy as:
Code:
class Admin extends CI_Controlelr{

  public function __construct()
  {
    parent::__construct();
    $this->load->library('auth_library');

    if ( ! $this->auth_library->is_admin() )
    {
       redirect('login');
    }
  }
}

//Routes
$route['admin/(:any)/(:any)'] = '$1_admin/$2'; // admin/blog/index => blog_admin/index
$route['admin/(:any)']        = 'admin/$1';    // admin/index      => admin/index
$route['admin']               = 'admin/index'; // admin            => admin/index

I like to create an admin controller for each module/controller, so you don't end up with some large Admin controller. Again, this allows you to create a frontend & backend controllers you can move to different projects. I use the admin controller for only the "dashboard" part of the backend.