【问题标题】:how to run one function on every page in codeigniter如何在codeigniter的每一页上运行一个函数
【发布时间】:2017-04-18 02:10:39
【问题描述】:

我正在制作一个基于 codeigniter 的网站。我的索引页中有页眉和页脚。

这是我的控制器:

 <?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);

        }
    }
    ?>

这在索引页上运行良好,但我想在每一页上都获得页眉和页脚。如您所见,我正在加载索引页面的视图。如何在每一页上获取页眉和页脚???请帮帮我。

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    使用这个

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 2014-02-08
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      相关资源
      最近更新 更多