找回密碼
 註冊
搜索
查看: 1592|回復: 0

[教學] OpenCart 模板創建module 簡單步驟

[複製鏈接]
發表於 2014-10-15 16:55:38 | 顯示全部樓層 |閱讀模式
 
Push to Facebook

假如我想創建一個側邊欄模塊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;
 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-5-1 12:00 , Processed in 0.020669 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表