Welcome Guest, Not a member yet? Register   Sign In
extending controllers
#1

[eluser]dimis[/eluser]
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?
#2

[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 :
Code:
class Public_Controller extends Controller {
    function Public_Controller() {
        parent::Controller();
... load your libraries and model u want to use in public access

}

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

[eluser]Dimitrio[/eluser]
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.

Thnx
#4

[eluser]TheFuzzy0ne[/eluser]
$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.
#5

[eluser]Dimitrio[/eluser]
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.




Theme © iAndrew 2016 - Forum software by © MyBB