Reputation: 2686
hi this is my controller :
public function index()
{
$data['menu'] = $this->load->view('frontend/menu/main_menu_view');
$this->load->view('frontend/header/header_view',$data);
$this->load->view('frontend/home/index_view');
}
and this is the code from the index_view view :
echo $menu;
but is not working, what should I do ? thx
Upvotes: 0
Views: 42
Reputation: 34
You can call
$this->load->view('frontend/menu/main_menu_view');
from inside any view file and it will load and display for you.
Upvotes: 1
Reputation: 797
The third parameter of $this->load->view()
doesn't load the view but returns it as 'data', to do with it what you please, muwahhahah! Sorry.
$data['menu'] = $this->load->view('frontend/menu/main_menu_view' , '', true);
You can still pass $data
into that view.
So from inside of
$this->load->view('frontend/header/header_view',$data);
you will echo $menu
Scroll to the bottom of the docs
Upvotes: 1
Reputation: 2686
In the view, you have to write just this :
<?php
$this->view('frontend/menu/main_menu_view');
?>
Upvotes: 0
Reputation: 61
Don't know if you copied this from your code or made a typo while typing your question, here, but shouldn't it be
echo $menu;
instead of
echo menu;
?
edit: Also, haven't worked with Codeigniter in a while, but why pass $data to the header_view and call it from the index_view instead ?
Upvotes: -1