Best method of including views within views in CodeIgniter

前端 未结 6 713
时光说笑
时光说笑 2020-11-28 02:57

I\'m starting a large codeigniter project and would like to try to create some reusable \'mini\' views for snippets of content like loops of data which may be displayed on d

6条回答
  •  清歌不尽
    2020-11-28 03:27

    This a simple way of including views within views.there is no need to load views in advance.just pass view path to other view.

    In your controller use this:

    $data['middle'] = 'includeFolder/include_template_view';  //the view you want to include
    $this->load->view('main_template_view',$data);  //load your main view
    

    and in main_template_view you can include other views :

    $this->load->view($middle);
    

提交回复
热议问题