• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sharing data between view partials

#2
[eluser]darrenm[/eluser]
I use a slightly different approach. I abstract my view loading into a custom library called Page.

This lib has functions for adding and removing style sheets and javascripts and a few other things. It then has a function called render_page() which loads all the various views required

Code:
function render_page($view,$data) {
  $this->CI->load->view('_header',$data);
  $this->CI->load->view($view,$data);
  $this->CI->load->view('_footer',$data);
}

you can then call this from your controller like so:

Code:
$data['docTitle'] = 'My document title';
$data['content'] = 'Page content';
$data['something'] = 'else';
$this->page->render_page('my_view_file',$data);

This keeps all $data in one array and has lots of scope for handling other common tasks (I use it in conjunction with a navigation generator for example).

Hope that helps


Messages In This Thread
Sharing data between view partials - by El Forum - 10-15-2008, 09:53 AM
Sharing data between view partials - by El Forum - 10-15-2008, 10:31 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:05 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:11 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:19 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:23 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:33 AM
Sharing data between view partials - by El Forum - 10-16-2008, 02:54 AM
Sharing data between view partials - by El Forum - 10-16-2008, 03:12 AM
Sharing data between view partials - by El Forum - 10-16-2008, 03:43 AM
Sharing data between view partials - by El Forum - 10-16-2008, 03:47 AM
Sharing data between view partials - by El Forum - 10-16-2008, 04:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.