3.1 控制器
系统控制器类位于control目录,控制器调度由framework/core/base.php中control()方法依据act和op参数完成,如果act或op参数为空,系统会自动赋值“index”。
控制器类文件名一般为业务名称,类名称一般为 业务名称 + “Control”,例如系统的品牌控制器类文件为control/brand.php,类名为brandControl
。
跟据商城业务需要,系统内置三个控制器父级类,BaseHomeControl
、BaseBuyControl
、BaseMemberControl
和BaseSellerControl
分别适用于前台展示、下单、会员中心、商家中心三类控制器,品牌展示需要继承BaseHomeControl
类。
<?php
/**
*
品牌展示
*
*
版权声明...
*/
defined
(
'InShopNC'
) or exit(
'Access Invalid!'
);
class
brandControl
extends
BaseHomeControl
{
public function
indexOp
(){
//
读取语言包
Language
::
read
(
'home_brand_index'
);
//
使用模型获得品牌列表
$model_brand
=
Model
(
'brand'
);
$brand_list
=
$model_brand
->
getBrandList
();
//
向模板抛出内容
Tpl
::
output
(
'brand_list'
,
$brand_list
);
//
设置页面标题
Tpl
::
output
(
'html_title'
,
Language
::
get
(
'brand_index_brand_list'
));
//
输出SEO设置信息
Model
(
'seo'
)->
type
(
'brand'
)->
show
();
//
调用模板展示
Tpl
::
showpage
(
'brand'
);
}
public function
searchOp
(){
/**
*
内容略...
*/
}
}
?>
访问http://<siteurl>/index.php?act=brand
将会执行
brandControl
类的indexOp
方法
访问http://<siteurl>/index.php?act=brand&op=search
将会执行brandControl
类的searchOp
方法