Reputation: 163
I am just on the beginning to learn CodeIgniter, I have one controller named home.php and I have 2 views named photo.php and body.php and I want to call the first view in the other. and finally calling body.php on acceuil.php.
How can I do this?
Upvotes: 1
Views: 93
Reputation: 929
In your body.php view
$this->load->view($content);
Here you can put whatever bod content
And in your controller
$data['content']='views/photo.php';
$this->load->view('body.php',$data);
Above method good for complex view structures like seperate header,footer and body files.But for your one can just do this way as well.
In your body.php
$this->load->view('photo.php');
And in your controller just load
$this->load->view('body.php');
Upvotes: 0
Reputation: 821
In the first view page ie in body.php you just write
$this->load->view('photo.php');
Upvotes: 3
Reputation: 450
You can also load the parent view and pass the child view as a parameter like this
$childview = $this->load->view('childview.php');
$this->load->view('parentview.php', array('childview' => $childview))
and than in parentview.php you just need to echo the variable $childview.
Upvotes: 0
Reputation: 5166
you can do it like this
in your first view body.php
$ci =& get_instance();//you have to do this because you are in output library
$ci->load->view('photo.php');
Upvotes: 0