:-: **模板调用方法**
* * * * *
如何通过微擎进入商城模块:
1,路由规则:
当传入的URL请求中包含一个名为 c、a、do(可选) 的 GET 参数,它即被视为一个路由,例如:
http://we7.cc/web/index.php?c=platform&a=menu&
则会路由至 /web/source/platform/menu.ctrl.php 文件中
http://we7.cc/app/index.php?c=mc&a=home&
则会路由至 /app/source/mc/home.ctrl.php 文件中
参数c->/web/source/或者/app/source/下面的文件夹名,具体看域名后的名称;
参数a->参数c文件夹下相应的文件名;
参数do->供a文件内程序判断用的参数,通过对此参数的判断以决定下一步的操作;
微商城在微擎里的url链接:http://wx.lemonbong.com/web/index.php?c=home&a=welcome&do=ext&m=ewei_shopv2
\web\source\home下有个welcome.ctrl.php文件,welcome.ctrl.php文件里有个:
~~~
elseif ($do == 'ext') {
$modulename = $_GPC['m'];
~~~
微商城在微擎的应用管理下有个链接:http://wx.lemonbong.com/web/index.php?c=module&a=display&do=switch&module_name=ewei_shopv2
\web\source\module下有个display.ctrl.php文件,display.ctrl.php文件里有:
~~~
if ($do == 'switch') {
$module_name = trim($_GPC['module_name']);
~~~
2,模板调用:
调用微擎中模板:
~~~
/**
* [WeEngine System] Copyright (c) 2013 WE7.CC
*/
$setting = $_W['setting'];//先获取全局设置
//将渲染web/themes/default/user/login.html文件
template('user/login');//user为web/themes/default/下的文件夹,login为user文件夹下的html文件名
~~~
调用商城模块中的模板:
~~~
class We7_demoModuleSite extends WeModuleSite { //类名与商城模块文件夹名称相同,并继承WeModuleSite类
public function doMobileIndex1() {
global $_W, $_GPC; //先设置全局变量
$title = '支付测试';
// 将渲染模块目录下的app端的模板文件,方法名要以doMobile开头
// addons/we7_demo/template/mobile/index1.html
include $this->template('index1'); //商城模块下template文件夹下的mobile文件夹下的html文件名
}
public function doWebManage() {
global $_W, $_GPC; //先设置全局变量
// 将渲染模块目录下的web端的模板文件,方法名要以doWeb开头
// addons/we7_demo/template/manage1.html
include $this->template('manage1'); //商城模块下template文件夹下的html文件名
}
}
~~~