We can load view into another view in codeigniter by creating a helper function and place the following code.
function loadView($view,$data = null){
$CI = get_instance();
return $CI->load->view($view,$data);
}
Next in the controller load helper function and then use this function in your view to load another one.
<?php
echo loadView('secondView',$data);
//where $data is the array
?>
Secondly We can also load view in another view by using this way also.
<?php
$data['val'] = $this->load->view('val', NULL, TRUE);
$this->load->view ('val2', $data);
?>
Where true indicates that it will return the content.
0 Comment(s)