指尖的殤魂 发表于 2012-7-21 11:11:50

大家都是怎样设计header和footer的啊

我用的是继承的方法,大家有什么好的方法啊,都出来说说,

指尖的殤魂 发表于 2012-7-21 11:14:01

搞得每次都要调用header和footer方法

gaoomei 发表于 2012-7-21 11:49:41

private function display($data = array(),$script='',$template_dir = '',$renderHF = true){
                if(!is_array($data)){
                        $data =array($data);
                }
                $this->load->vars($data);
                if(empty($template_dir)){
                        $template_dir = strtolower($this->_controller);
                }

                if(empty($script)){
                        $script = strtolower($this->_action);
                        if(empty($script)){
                                $script = 'index';
                        }
                }

                $template_dir = $template_dir.'/'.$script.'.php';
                if($renderHF){
                        $this->load->view('/header.php');
                        $this->load->view($template_dir);
                        $this->load->view('/footer.php');
                }else{
                        $this->load->view($template_dir);
                }
}

指尖的殤魂 发表于 2012-7-21 13:42:42

我看到有些人直接写在view视图里,却又找不到它们的control,没control怎么传递变量呢

Nebula 发表于 2012-8-16 14:56:44

Jeffery Way的视频里有提到过的。
view目录下建立include目录,在里面新建template.php

$this->load->view('include/header');
$this->load->view($template);
$this->load->view('include/footer');


控制器每次调用的时候是这样

$data['record'] = '要传递给视图的数据';
$data['template'] = '控制器对应的视图路径‘;
$this->load->view('include/template', $data);

大道达人 发表于 2012-10-10 09:41:54

本帖最后由 大道达人 于 2012-10-10 09:46 编辑

http://codeigniter.org.cn/forums ... iewthread&tid=12209
CIER小站 Zhao.Template(header-content-footer模板和提示设计)
页: [1]
查看完整版本: 大家都是怎样设计header和footer的啊