0
有沒有辦法在plates php中,我可以在控制器中創建模板,但使用其他控制器進行渲染。假設我有兩個控制器。 HeaderController和一個SearchController。有沒有一種方法來製作模板,但不能在板中呈現php
SearchController
class Search extends \system\core\BaseController
{
public function Index()
{
$data['text_search'] = 'Search..';
// This $this->template->render down below is what I don't want now
// okay asign the data but do not display the template yet
echo $this->template->render('common/search', $data);
}
}
假人SearchController應指派$數據到模板search.tpl,但不顯示/顯示模板。
這是我將調用上述控制器
HeaderController
class HeaderController extends \system\core\BaseController
{
public function Index()
{
// Some codes
// Call/load the SearchController and asign it to $data['search']
$data['search'] = $this->load->controller('common/SearchController');
// and then pass all $data and render/display it.
echo $this->template->render('common/header', $data);
}
}
有沒有做這件事的呢?
tereško,男人..這是愚蠢的。謝謝哥們,回報有幫助。 – Mecom
@Mecom不客氣 –