標籤:splay xtend 檔案 顯示 function hid isp use dmi
模板檔案中,提交搜尋內容要用get方法,同時設定g、m、c隱藏欄位。
<form action="{:U(‘Sck/qbscHjsc‘)}" method="get"> <table class="search-tab"> <tr> <input type="hidden" name="g" value="<?php echo MODULE_NAME; ?>"> <input type="hidden" name="m" value="<?php echo CONTROLLER_NAME; ?>"> <input type="hidden" name="a" value="<?php echo ACTION_NAME; ?>"> <th width="120">素材名稱:</th> <td> <input class="common-text" name="mingcheng" size="20" value="" type="text"> </td>
controller中處理
// 素材庫 環境素材檢索public function qbscHjsc(){ $where = ‘ fenxiang=1 ‘; // 查詢參數 if(I(‘request.leixing‘)!=‘‘){ if(I(‘request.mingcheng‘) != ‘‘){ $where .= ‘ and mingcheng like \‘%‘.I(‘request.mingcheng‘).‘%\‘ ‘; } } ... $sck_model=M("Kczz_sck"); $count=$sck_model->where($where)->count(); $page = $this->page($count, 10); $list = $sck_model ->where($where) ->order("id desc") ->limit($page->firstRow . ‘,‘ . $page->listRows) ->select(); $this->assign(‘list‘, $list); $this->assign(‘page‘, $page->show(‘Admin‘)); $this->display();}
如果是前台的controller,需要自己匯入page類
<?phpnamespace Home\Controller;use Think\Controller;class IndexController extends Controller { public function sck(){ $where = ‘ fenxiang=1 ‘; // 查詢參數 if(I(‘request.leixing‘)!=‘‘){ if(I(‘request.mingcheng‘) != ‘‘){ $where .= ‘ and mingcheng like \‘%‘.I(‘request.mingcheng‘).‘%\‘ ‘; } } ... $sck_model=M("Kczz_sck"); import(‘ORG.Util.Page‘); // 匯入分頁類 $count=$sck_model->where($where)->count(); $Page = new \Think\Page($count,5); $show = $Page->show(); // 分頁顯示輸出 $list = $sck_model ->where($where) ->order("id desc") ->limit($Page->firstRow . ‘,‘ . $Page->listRows) ->select(); $this->assign(‘list‘, $list); $this->assign(‘page‘, $show); $this->display(); }}
模板處翻頁代碼
<div class="list-page"> {$page}</div>
thinkphp 帶檢索參數分頁