![]() |
Passing data to a view within a view: Why doesn't this work? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Passing data to a view within a view: Why doesn't this work? (/showthread.php?tid=32339) |
Passing data to a view within a view: Why doesn't this work? - El Forum - 07-20-2010 [eluser]dallen33[/eluser] Code: $title = 'Home'; In the view header.php, I have <?php echo $title; ?> Any idea why this doesn't work? The error is that title is an undefined variable. Passing data to a view within a view: Why doesn't this work? - El Forum - 07-20-2010 [eluser]dallen33[/eluser] Controller Code: $data['title'] = 'Home'; View Code: <?php echo $this->load->view('header', $data); ?> This works, but seems clumsy. Passing data to a view within a view: Why doesn't this work? - El Forum - 07-20-2010 [eluser]WanWizard[/eluser] Shouldn't the second parameter be an array? Code: $data['title'] = 'Home'; Passing data to a view within a view: Why doesn't this work? - El Forum - 07-20-2010 [eluser]dallen33[/eluser] Works, thanks! |