2017-04-18 84 views
-1

我想在視圖中包含一些其他視圖部件,如content1,content2,.etc。 在Codeigniter中是否存在懶惰,就像Laravel @yield一樣。 對不起,如果它是愚蠢的問題。包含視圖內的其他視圖

+0

這是一個codeigniter問題,而不是laravel相關。 –

+0

謝謝,它修正:) –

回答

0

我找到了解決方案,我會分享它。 所以在SomePage的控制器需要的頁面的部分叫separatle,並把它放在一個數組中:

<?= $head; ?> 
<?= $header; ?> 
<?= $body; ?> 
<?= $footer; ?> 
<?= $foot; ?> 

我:

public function index() 
{ 
     $this->_dataOut['head'] = $this->load->view('head','', TRUE); 
     $this->_dataOut['header'] = $this->load->view('layout/header','',TRUE); 
     $this->_dataOut['body'] = $this->load->view('publicPages/welcome_message','',TRUE); 
     $this->_dataOut['footer'] = $this->load->view('layout/footer','',TRUE); 
     $this->_dataOut['foot'] = $this->load->view('foot','',TRUE); 
     $this->load->view('mainPage', $this->_dataOut); 
} 

,比我們可以通過索引這樣調用傳輸的數據希望它能幫助某個人,不然。 :) 我很高興分享,有一個很好的編碼日。 :)