How can i prevent the loading of index function with __construct in CodeIgniter?

reg4download

New Member
i am building admin area for my app with CodeIgniter, i created a base Admin Controller in the library named: MY_Admin_Base that extends the CI Controller. and there i checking in the DB if the admin has access to the method.\[code\]class MY_Admin_Base extends Controller { function __construct() { parent::Controller(); //check if the admin has premission to the page $this->load->model('admin_permissions_model'); $query = $this->admin_permissions_model->get_admin_permission( array( 'admin_id'=>$this->session->userdata('admin_id'), 'page_id'=>$pages_cat_id) ); if(!$query) $this->view->load('admin/restricted_area'); }}\[/code\]the main class extends that MY_Admin_Base, and has index method, something like that:\[code\]class Main extends MY_Admin_Base { function __construct() { parent::__construct(); } function index() { $this->view->load('admin/main'); }}\[/code\]the problem is that the both the views are loaded if the admin does`nt have access...the restricted and the main view.someone have any suggestion?
 
Back
Top