0
votes

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

4

4 Answers

1
votes

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

1
votes

You can call

$this->load->view('frontend/menu/main_menu_view');

from inside any view file and it will load and display for you.

0
votes

In the view, you have to write just this :

<?php 
$this->view('frontend/menu/main_menu_view');
?>
-1
votes

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 ?