|
假如我想創建一個側邊欄模塊sidebar,讓每一個頁面都可以復用,步驟如下:
1. 在controller/module目錄下新建sidebar.php文件。
2. 添加文件內容為:
class ControllerModuleSidebar extends Controller {
protected function index($setting) {
$this->template = $this->config->get('config_template') . '/template/module/sidebar.tpl';
$this->render();
}
}
3. 在template/module創建sidebar.tpl模板文件。
4. 在調用的controller引用:
$this->data['sidebar'] = $this->getChild('module/sidebar');
5. 在模板文件使用: echo $sidebar; |
|