Login box on multiple pages |
[eluser]Funky Fresh[/eluser]
Hey Hey, I have been reading the article at http://codeigniter.com/wiki/Header_and_F...ge_-_jedd/ for quite some time and i cant wrap my head around how to pull this off. So im going to post my code here in hopes that someone can help me. Im trying to include a 'login box' on certain pages of my site ... if you could check it out that would be great. I extended my core controller and created MY_Controller.php which is as follows Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); In the view that i want to display the login box i have the following code. Code: <?php echo $login_box_view; ?> When i load up the page, i get the following error Quote:A PHP Error was encountered I think im missing something hehe ... can someone please help me out. Cheers,
[eluser]SpooF[/eluser]
Can you post your other controller code? Like the code that is being executed where your loading the view thats giving you the error?
[eluser]Funky Fresh[/eluser]
Im using the Tank Auth library, here is the controller Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); It's the line that loads the notloggedin_index view. Cheers,
[eluser]dark_lord[/eluser]
Change this: Code: $this->data['login_box_view'] = $this->load->view('inc/login_form', $tmp_data, TRUE); To something like: Code: $data['header'] = $this->load->view('inc/header', $tmp_data, TRUE); Then pass it to another view: Code: $this->load->view('inc/login_page', $data);
[eluser]dark_lord[/eluser]
Change this: Code: $this->data['login_box_view'] = $this->load->view('inc/login_form', $tmp_data, TRUE); To something like: Code: $data['header'] = $this->load->view('inc/header', $tmp_data, TRUE); And on the view: Code: <?php echo $header; ?>
[eluser]SpooF[/eluser]
In your MY_Controller your saving your data into a class variable called data. In your controller your passing the local variable data and not the class variable. Change this: Code: $data['user_id'] = $this->tank_auth->get_user_id(); to: Code: $this->data['user_id'] = $this->tank_auth->get_user_id();
[eluser]Funky Fresh[/eluser]
Hey SpooF, That worked perfect ... thanks heaps for that ... So to sum it up ( sorry about this ) ... using $data is only local and when using $this->data is more global? |
Welcome Guest, Not a member yet? Register Sign In |