Need Help Passing Controllers/Views As Arrays - 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: Need Help Passing Controllers/Views As Arrays (/showthread.php?tid=59595) |
Need Help Passing Controllers/Views As Arrays - El Forum - 10-25-2013 [eluser]razerone[/eluser] Hi I am need to pass a couple of views as arrays how do I do so. I came up with this but not quite working. Code: $this->children = array( Need Help Passing Controllers/Views As Arrays - El Forum - 10-25-2013 [eluser]PravinS[/eluser] you can also try like this $data['footer'] = 'common/footer'; $data['header'] = 'common/header'; $this->load->view('template',$data); and include this views in view as include($header); include($footer); Need Help Passing Controllers/Views As Arrays - El Forum - 10-25-2013 [eluser]razerone[/eluser] [quote author="PravinS" date="1382704728"]you can also try like this $data['footer'] = 'common/footer'; $data['header'] = 'common/header'; $this->load->view('template',$data); and include this views in view as include($header); include($footer); [/quote] <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Home extends CI_Controller { public function index() { $this->load->helper('array'); $this->load->helper('path'); if (file_exists('views/theme' . 'default/template/common/home.tpl')) { $this->load->view('theme'. 'default/template/common/home.tpl'); } else { $this->load->view('theme/default/template/common/home.tpl'); } $this->children = array( 'common/footer', 'common/header' ); } } This is way I have done but need to use array or some thing suitable Need Help Passing Controllers/Views As Arrays - El Forum - 10-25-2013 [eluser]PravinS[/eluser] try using in controller Code: $children = array("common/footer","common/header"); in view Code: foreach($children as $file) Need Help Passing Controllers/Views As Arrays - El Forum - 10-25-2013 [eluser]razerone[/eluser] [quote author="PravinS" date="1382707432"]try using in controller Code: $children = array("common/footer","common/header"); in view Code: foreach($children as $file) No Luck |