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

#9
[eluser]xwero[/eluser]
With you new code you are not adding the partials to the master view file.
Code:
$glob_partials['title'] = 'My Great Title';

$master['content'] = $this->load->view('content_partial_view', $glob_partials, TRUE);
$master['sidebar']  = $this->load->view('sidebar_partial_view', $glob_partials, TRUE);

$this->load->view('master', $master);
This code is more readable and flexible. Lets say there are some other variables needed for the content then you can do
Code:
$glob_partials['title'] = 'My Great Title';

$content = array_merge($glob_partials,array('body'=>'long text'));

$master['content'] = $this->load->view('content_partial_view', $content, TRUE);
$master['sidebar']  = $this->load->view('sidebar_partial_view', $glob_partials, TRUE);

$this->load->view('master', $master);
Do you see now how something simple like naming arrays differently can make your code better.


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.