opencart架构网站,magento模板创建
2022-11-04 10:40:07 - 米境通跨境电商
在opencart中假如我想创建一个侧边栏模块sidebar,让每一个页面都可以复用,步骤如下:
1.在controller/module目录下新建sidebar.php文件。
2.添加文件内容为:
classControllerModuleSidebarextendsController{
protectedfunctionindex($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;