简体   繁体   中英

how to run one function on every page in codeigniter

I am making a site based on codeigniter. I have a header and footer in my index page.

Here is my controller:

 <?php
    defined('BASEPATH') OR exit('No direct script access allowed');

    class Travels extends CI_Controller {

         function __construct(){
            parent :: __construct();
            $this->load->model('travel');
        }

        public function index()
        {
    $data= array(
                'menu_products'=>$this->travel->menu_products();
                'footer_products'=>$this->travel->footer_products();
    );
               $this->load->view('index', $data);

        }
    }
    ?>

This is working fine on the index page, but I want to get that header and footer on every page. As you can see I am loading view of index page. How I can get Header and footer on every page??? Please help me out.

use this

$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM