You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.0 KiB
PHP

<?php
namespace Home\Controller;
/**
* 前台首页控制器
* 主要获取首页聚合数据
*/
class SiteAdvController extends BaseController {
const model_name = 'SiteAdv';
//站点申请
public function index($p=0){
$row = 10;
$model = D(self::model_name);
$result = $model->lists($p);
$count = $result['count'];
//分页
$parameter['p']=I('get.p',1);
$parameter['row']=I('get.row');
$page = set_pagination($count,$row,$parameter);
if($page) {$this->assign('_page', $page);}
$this->assign('data',$result['data']);
$this->meta_title = "广告列表";
$this->display();
}
public function add(){
$model = D(self::model_name);
if(IS_POST){
$res = $model->update($_POST);
if($res !== false){
$this->success('添加成功!');
}else{
$this->error('添加失败:'.$model->getError());
}
}else {
$this->assign('position',$model->position());
$this->meta_title = "添加广告";
$this->display();
}
}
public function edit($id=0){
$model = D(self::model_name);
if(IS_POST){
$res = $model->update($_POST);
if($res !== false){
$this->success('编辑成功!');
}else{
$this->error('编辑失败:'.$model->getError());
}
}else {
$data = $model->detail($id);
$this->assign('data',$data);
$this->assign('position',$model->position());
$this->meta_title = "编辑广告";
$this->display();
}
}
public function del(){
$model = D(self::model_name);
if ($model->del()) {
$this->ajaxReturn(array('status'=>1,'msg'=>'操作成功'));
} else {
$this->ajaxReturn(array('status'=>0,'msg'=>$model->getError()));
}
}
}