我想让两个方法调用一个视图(同一个控制器)。我怎样才能做到这一点。例如,这是一个到视图的路径
Route::get('url', 'ExampleController@foo');
Route::get('url', 'ExampleController@bar');
如何合并这两者。
答案 0 :(得分:0)
You need to code in controller methods i.e
class ExampleController extends CI_Controller {
public $data;
public function foo(){
//inside foo get the view of bar in variable i.e.
$this->data['bar_view'] = $this->load->view('bar_view',$this->data,true);
$this->load->view('foo_view',$this->data);
}
public function bar(){
//inside foo get the view of bar in variable i.e.
$this->data['foo_view'] = $this->load->view('foo_view',$this->data,true);
$this->load->view('bar_view',$this->data);
}
}
// inside view display as the order you want