Ecstore中finder”查看”下的分页实现
生活随笔
收集整理的這篇文章主要介紹了
Ecstore中finder”查看”下的分页实现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我們經常在finder中使用”查看”列出改條數據的一些詳細信息,那么如果列出的信息太多導致一個頁面放不下了怎么辦呢?今天我就給大家講講如何在finder“查看”中進行分頁。
首先,我們需要在lib/finder/xxx.php中添加構建函數__construct(),進行一些參數設定:
class notebook_finder_item{public function __construct($app){$this->app = $app;$this->render = app::get('notebook')->render();$this->controller = app::get('notebook')->controller('admin_notebook');$this->pagelimit=10;}然后,在“查看”的方法中做以下修改:
function detail_email($id){if(!$id) return null;$render = app::get('notebook')->render();$nPage = $_GET['detail_email'] ? $_GET['detail_email'] : 1;$singlepage = $_GET['singlepage'] ? $_GET['singlepage']:false;$Oemail = kernel::single("notebook_mdl_item");$items = $Oemail->db->select('select item_email from sdb_notebook_item limit '.$this->pagelimit*($nPage-1).','.$this->pagelimit);$this->render->pagedata['item'] = $items;if($_GET['page']) unset($_GET['page']);$_GET['page'] = 'detail_email';$count =$Oemail->count();$render->pagedata['pager']=$a=$this->controller->pagination($nPage,$count,$_GET);return $this->render->fetch('admin/itememail.html');}同時,我們要把detail_edit復制一份放到對應的controller中,添加如下函數:
class notebook_ctl_admin_notebook extends desktop_controller{var $workground = 'notebook_ctl_admin_notebook';var $pagelimit = 10;public function __construct($app){parent::__construct($app);header("cache-control: no-store, no-cache, must-revalidate");}function detail_email($id=null){if(!$id) return null;$render = $this->app->render();$nPage = $_GET['detail_email'] ? $_GET['detail_email'] : 1;$Oemail = kernel::single("notebook_mdl_item");$items = $Oemail->db->select('select item_email from sdb_notebook_item limit '.$this->pagelimit*($nPage-1).','.$this->pagelimit);//print_r($nPage);die;$render->pagedata['item'] = $items;if($_GET['page']) unset($_GET['page']);$_GET['page'] = 'detail_email';$count =$Oemail->count();$render->pagedata['pager']=$this->pagination($nPage,$count,$_GET);return $render->fetch('admin/itememail.html');}public function pagination($current,$count,$get){ //本控制器公共分頁函數$app = app::get('notebook');$render = $app->render();$ui = new base_component_ui($this->app);$link = 'index.php?app=notebook&ctl=admin_notebook&act=ajax_html&id='.$get['id'].'&finder_act='.$get['page'].'&'.$get['page'].'=%d';//echo $link;$this->pagedata['pager'] = $ui->pager(array('current'=>$current,'total'=>ceil($count/$this->pagelimit),'link' =>$link,));return $this->pagedata['pager'];}public function ajax_html(){$finder_act = $_GET['finder_act'];//print_r($_GET['id']);die;$html = $this->$finder_act($_GET['id']);echo $html;}最后一步,在html頁面中要顯示分頁信息的地方,加入變量<{$pager}>,就OK了!
總結
以上是生活随笔為你收集整理的Ecstore中finder”查看”下的分页实现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 博弈论——蒋文华
- 下一篇: 华为海思2022数字芯片笔试题(节选)