creating a master template in CodeIgniter

后端 未结 2 748
闹比i
闹比i 2021-01-06 14:33

I am stuck with a very basic problem. Ook the problem is this that I want a master template in which I can call the header, body and footer. I am unable to send title and cs

2条回答
  •  渐次进展
    2021-01-06 15:13

    hi there is different method to use template in codeigniter .

    1- you can use this procedure

    In controller

     $data['main_content'] = 'login_view';  
     $data['title']        = 'Login To WePOS';  
     $data['css']          = 'login-box.css';  
     $this->load->view('templates/default',$data);
    

    In template.php View

    $this->load->view('header_view');  
     $this->load->view($main_content);   
     $this->load->view('footer_view');  
    

    in your main content variable you can pass the view file

    if you want to add multiple css or multiple js files you can use MY_MARK idea as

    $data['cssFiles'] = array(
        'login-box.css',
        'other.css'
    );  
    

    and in your header file

     if(is_array($cssFiles)){
        foreach($cssFiles as $cssFile) {
            
        }
    }
    

    Hope it helps.

提交回复
热议问题