opencart
opencart | git opencart | fornum | blog | document
opencart
2019-01-29
2017-12-29
2017-06-18
vqmod下载
https://github.com/vqmod/vqmod/releases
原理:在/index.php中加入如下代码:
require_once('./vqmod/vqmod.php');
VQMod::bootup();
require_once(VQMod::modCheck(DIR_SYSTEM . 'startup.php'));
在/admin/controller/extension下安装installer.php和modification.php
系统运行时到/vqmod/xml查找替换文件的xml,替换原文件来执行。
下载解压,将vqmod目录上传到opencart根目录,
在浏览器上输入:/vqmod/install, 会显示:VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!
第二次:/vqmod/install, 就会出现:VQMOD ALREADY INSTALLED!
判断用户是否登录的方法
if (isset($this->request->get['token']) &&
isset($this->session->data['token']) &&
($this->request->get['token'] == $this->session->data['token'])) {}
if ($this->user->isLogged() &&
isset($this->request->get['token']) &&
($this->request->get['token'] == $this->session->data['token'])) {}
多语言显示信息:
$this->load->language('common/login'); 加载一个语言目录
$this->language->get('error_login'); 检索语言对应的文字
多语言的文字检索是先在控制器中完成,加载到模板中显示
MVC机制:
index.php?route=common/login
系统加载控制器:/catelog/controller/ControllerCommonLogin,并调用index()方法
在控制器中设置数据$data, 加载view模板, 并显示网页
$this->response->setOutput($this->load->view('common/login.tpl', $data));
模板目录在:/catelog/view/template/common/
只返回模板数据,不显示
return \(this->load->view('common/column_left.tpl', \)data);
重定向到新地址
$this->response->redirect($this->url->link('common/dashboard', 'token=' . $this->session->data['token'], 'SSL'));
主页是如何检索布局layout_id
依路由$route来判断:
1.如果是'product/category', 则layout_id = getID('product/category');
2.如果是'product/product', 则layout_id = getID('category/product');
3.如果是'information/information', 则layout_id = getID('catalog/information');
4.其它layout_id = getID($route)
select layout_id from layout_route where route like $route and store_id = $store_id;
5.取出layout_id对应的模组(有多个模组)
select * from layout_module where layout_id = $layout_id and position = 'left'
6.加载相应的模组(模组定义高度和宽度,显示条目的数量)
加载相应的模板文件:template\module下
\catalog\view\theme\default\template\module\special.tpl
layout_module.code: 如special.34, 34是module.module_id, special.tpl可能会有多个module的配置
7.模组的信息是来自\catalog\controller\module\special.php
名称来自:catalog\language\chinese\module\special.php
$_['heading_title'] = '优惠商品';
select * from oc_layout_route where 'common/home' like route;
select * from oc_layout where layout_id = 1;
select * from oc_layout_module where layout_id = 1;
select * from oc_module where code = 'special';
select * from oc_extension code = 'newsblog_articles';
select * from oc_extension;
select * from oc_extension;
测试样本
http://127.0.0.1/upload/index.php?route=product/product&path=20_27&product_id=42 http://127.0.0.1/upload/admin/index.php?route=catalog/product/edit&token=3cf911e71623a959fd1ed973458825a3&product_id=42
向商品中增加属性
attribute id attribute_group 属性组 attribute_desciption 属性多语言的文字 attribute_group_desciption 属性组多语言的文字 product_attribute 属性的id和value
index.php加载过程
1.加载config.php:
加载路径和数据库设置
2.加载startup.php
解析服务请求,
自动加载模块spl_autoload_register.(\system\library)
加载基本模块(\system\engine目录下)
// Front Controller
$controller = new Front($registry);
// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance'));
// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));
// Router
if (isset($request->get['route'])) {
$action = new Action($request->get['route']);
} else {
$action = new Action('common/home');
}
// Dispatch
$controller->dispatch($action, new Action('error/not_found'));
// Output
$response->output();