• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
extending controllers

I have a site with the front end and the back end.
I want to create 2 controllers that will extend the core controller (MY_Frontcontroller,MY_Backcontroller) and the controllers of front end and back end to extend them.
Can I do this, to make 2 separate classes that extend one core class and then extends them at my controllers?

[eluser]Sarfaraz Momin[/eluser]
you can create a My_controller library which would extend the controller class and then in that you can create 2 seperate classes which would be for public and private access. Something like this :
class Public_Controller extends Controller {
    function Public_Controller() {
... load your libraries and model u want to use in public access


class Auth_Controller extends Public_Controller {
    function Auth_Controller() {
        if ($this->data->user === FALSE) {
            header('Location: '.$this->config->item('base_url').'login');
        } else {

Quote:if ($this->data->user === FALSE) {
header('Location: '.$this->config->item('base_url').'login');

I am very new to CI, can someone please explain to me what the "$this->data->user" is, and where CI gets it from,

as well as the "header".

I am trying to use erkana auth to only show a menu in my Header_view if the person is logged in, but I keep on getting errors, I think I might be able to solve it once I understand these two concepts.


$this->data->user has nothing to do with CI. That is a property that belongs to the auth library itself.

The header() call redirects the user to the login page if they aren't logged in.

Thank you for clearing that up.

I think I am going to drop that and just load an extra view "Menu_view" when the person logs in.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.