Question about template |
[eluser]Carmichael[/eluser]
Hi. I've four files I want to include in every page. common/header.php common/sidebar_left.php common/sidebar_right.php common/footer.php Now I use $this->load>view('common/sidebar_left') to include common/sidebar_left in the header and $this->load>view('common/sidebar_right') to include common/sidebar_right in the footer. header Code: // some shitty stuff here footer Code: // some shitty stuff here And then in all controllers I get three view files: Code: $this->load->view('common/header'); The problem is sidebar_left and sidebar_right don't get data from their controllers. I have one controller where I build widgets to the sidebar's. The content from sidebar_right/left does get included but not the data from the controller that provides sidebar_right/left with data.
[eluser]Samus[/eluser]
You should really be using the template library for something like this. But what you could do is create a view file called template. within the template view, you'd include all of these: $this->load->view('common/header'); $this->load->view('controller_view'); $this->load->view('common/footer'); Then just load template in your controller and pass your $data to it. $this->load->view('template', $data);
[eluser]Carmichael[/eluser]
That doesn't solve the problem. The view files still needs to get data from it's controllers.
[eluser]Samus[/eluser]
[quote author="Carmichael" date="1333880696"]That doesn't solve the problem. The view files still needs to get data from it's controllers.[/quote] if you pass the $data array to the template view, they will.
[eluser]InsiteFX[/eluser]
Maybe you should read the CodeIgniter Users Guide on Views, because you sure do not seem to know how to use them! CodeIgniter Users Guide -Views
[eluser]Carmichael[/eluser]
I just don't understand how I pass data from a controller to a another controller. It's easy to just load views (header, footer) in a controller but my files has variable data that do not come off when I load the files.
|
Welcome Guest, Not a member yet? Register Sign In |