2013-02-26 94 views
6

我一直在使用Django一段時間,我決定啓動一個新項目,但這次在Codeigniter中,我用來在我的視圖中擴展模板文件,並將內容放入{%block內容%}塊,但它在CodeIgniter中不同。在另一個視圖中加載視圖

CI中我有類似:

<?php 
    $this->load->view('header'); 
    $this->load->view('form_add_customer'); 
    $this->load->view('footer'); 
?> 

但是,有沒有辦法有標題,內容和頁腳這樣一個獨特的文件?

<html> 
    <head><title>Test</title></head> 
    <body> 
     <div id="header">Welcome</div> 
     <div id="content"> 
     </div> 
     <div id="footer"> 2013 - Tectcom Telecom</div> 
    </body> 
</html> 

並把一個視圖文件與一個窗體裏面的內容div?

回答

9

更新HTML(佈局)文件是這樣的:

<div id="content"><?php $this->load->view($content) ?></div> 

在你的控制器,稱這樣的觀點:

$view_data = array(); 
$view_data['content'] = 'form_add_customer'; 
$this->load->view('path/to/layout', $view_data); 
相關問題