Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter, passing object to view

I have the following in my codeigniter constructor:

$navbar= new stdClass(); 
$navbar->user_email = $this->user_email;
$navbar->vp = $this->vp;

When I try to access this in my index function:

public function index() {

     var_dump($this->navbar);

this works.

I now tried to pass $this->navbar to the view with:

$this->load->view('buyers/navbar', $this->navbardata);

In the view I have

<?php echo 'in nav ';var_dump($this->navbar); exit; ?>

I get :

Message: Undefined property: MY_Loader::$navbar    

How can I make this work?

Thanks in advance,

like image 905
user1592380 Avatar asked Jun 04 '13 04:06

user1592380


1 Answers

Try like this

$data['navbar'] = $this->navbardata;
$this->load->view('buyers/navbar', $data);

and in your view try like

<?php echo 'in nav ';var_dump($navbar); exit; ?>
like image 100
Gautam3164 Avatar answered Sep 28 '22 17:09

Gautam3164