Welcome Guest, Not a member yet? Register   Sign In
Load Navigation Bar Controller For Every Page Automatically
#1

[eluser]kingnutter[/eluser]
Hi everyone,

I have just styled a Codeigniter website with Bootstrap and would like the "Log In" form in the navigation bar to pop up as a modal.

Pasting the form into the view results in undefined variables $login_by_username and $show_captcha (I am using the tank_auth library).

I currently load a template view in each controller containing header, nav, body view and footer, but how can I call the above variables without having to change every controller function? I am already have $this->load->library('tank_auth'); in each __construct.

Basically I need a universal controller that calls the tank_auth model to retrieve variables for a navbar sign in modal.

Any pointers welcome.

Cheers!
#2

[eluser]boltsabre[/eluser]
Quote:I am already have $this->load->library(‘tank_auth’); in each __construct.
Why not then just autoload it in config/autoload.php???

Quote:Basically I need a universal controller that calls the tank_auth model to retrieve variables for a navbar sign in modal.
What your after is a "MY_Controller". There are a gazillion blog posts, threads on here and stackoverflow about how to do this, so I'll let you do your own research on that one, but it's what your after.
One little hint, inside the MY_Controller you'll want to use $this->load->vars() to get your two variables accessible in your views without needing to manually pass them in from every controller. So research that as well ;-)




Theme © iAndrew 2016 - Forum software by © MyBB