1.改写删除方法
function pre_recycle($rows) {
if(is_array($rows)){
foreach($rows as $key => $val){
if(!($val['status'] == '3')) {
$this->recycle_msg = '只可对审核未通过的商品进行删除';
return false;
}
}
}
return true;
}
2.更改finder分页效果
'object_method' => array(
'count'=>'countshopactivity', //获取数量的方法名
'getlist'=>'getList', //获取列表的方法名
3.关联主键
'act_id' =>
array (
'type' => 'table:activity',
'label' => '所属活动',
'required' => true,
'in_list' => true,
'editable' => false,
'searchtype' => 'has',
),
save()---当含有主键,为更新;不含有时,为插入操作
结果的详细列表显示中,所属活动ID,自动变成活动名称
4.搜索条件设置
$FilterArray= array( 'than'=>' > '.$var, 'lthan'=>' < '.$var, 'nequal'=>' = \''.$var.'\'', 'noequal'=>' <> \''.$var.'\'', 'tequal'=>' = \''.$var.'\'', 'sthan'=>' <= '.$var, 'bthan'=>' >= '.$var, 'has'=>' like \'%'.$var.'%\'', 'head'=>' like \''.$var.'%\'', 'foot'=>' like \'%'.$var.'\'', 'nohas'=>' not like \'%'.$var.'%\'', 'between'=>' {field}>='.$var[0].' and '.' {field}<'.$var[1], 'in' =>" in ('".implode("','",(array)$var)."') ", 'notin' =>" not in ('".implode("','",(array)$var)."') ", );
$filter=array('item_id|than'=>4,item_id|between'=>array(4,6));
'item_content|in'=>1234,656 ==='item_content|in'=>1234
5.多表连接
model/item
var $has_many = array(
'order' => 'order:contrast:id^item_id',//后者为order表字段
);
var $subSdf = array(
'default' => array(
'order' => array('order_num',null,array( 0,2,'order_id DESC' )),
),
'delete' => array(
'order'=>array('*'),
),
);
Controller
$items=$this->app->model('item')->dump($filter,"id,item_subject",'default');//必须含有主键
级联删除 delete($filter,'delete');
6.前台控制器
Function index()
{
$this->path[] = array('title'=>app::get('notebook')->_('留言板中心'),'link'=>$this->gen_url(array('app'=>'notebook', 'ctl'=>'site_default', 'act'=>'index','full'=>1)));
$GLOBALS['runtime']['path'] = $this->path;
.......
$this->output(); }
protected function output($app_id='notebook'){
$this->page('site/index.html');
}
7.修改dump方法
function dump($filter,$field = '*',$subSdf = null){
if($ret = parent::dump($filter,$field,$subSdf)){
$ret['profile']['birthday'] = $ret['b_year'].'-'.$ret['b_month'].'-'.$ret['b_day'];
if($ret['profile']['gender']== 1){
$ret['profile']['gender'] = 'male';
}
elseif($ret['profile']['gender']== 0){
$ret['profile']['gender'] = 'female';
}
else{
$ret['profile']['gender'] = 'no';
}
}
return $ret;
}
8.finder查看下的分页效果
public function pagination($current,$count,$get){ //本控制器公共分页函数
$app = app::get('activity');
$render = $app->render();
$ui = new base_component_ui($this->app);
//unset($get['singlepage']);
$link = 'index.php?app=activity&ctl=admin_application&act=ajax_html&id='.$get['id'].'&finder_act='.$get['page'].'&'.$get['page'].'=%d';
$this->pagedata['pager'] = $ui->pager(array(
'current'=>$current,
'total'=>ceil($count/$this->pagelimit),
'link' =>$link,
));
}
public function ajax_html()
{
$finder_act = $_GET['finder_act'];
$html = $this->$finder_act($_GET['id']);
echo $html;
}
Finder和controller写两个一样的detail方法
ecstore二次开发技巧
最新推荐文章于 2022-08-20 17:55:21 发布