Loading multiple views using codeigniter php

后端 未结 2 804
忘掉有多难
忘掉有多难 2021-01-16 04:54

I have 4 pages in view such as

layout/header.php,
layout/header_assets.php,
user/main.php,
layout/footer.php

i want to load these multiple

2条回答
  •  长情又很酷
    2021-01-16 05:57

    You can create a folder includes under view and create a page template and add the below code in page template-

    load->view('includes/header');
        $this->load->view($middle);
        $this->load->view('includes/footer');   
    ?>
    

    And in your controller you can just call the template and pass your data like below-

    $this->data['middle'] = 'public/existing_mem'; // view page to be included
     $this->load->view('includes/template',$this->data);
    

提交回复
热议问题