具体效果大家可以去我博客查看,里面有详细解说https://www.hwt.ink/portal/article/index/id/22.html
ThinkCMF中默认是使用Bootstrap进行分页的,那么ThinkCMF中如何使用Layui样式进行分页显示?
1、在需要使用到的模块的配置文件夹(config)中,添加paginate.php文件
paginate.php文件配置的具体内容:
<?php return [ 'type' => '\\plugins\\paginate\\paginator\\Layui', 'var_page' => 'page', 'list_rows' => 15, ];
2、分页文件Layui.php配置的具体内容:
protected function getNextButton($text = '') { if (empty($text)) { if (empty($this->options['next'])) { $text = "»"; } else { $text = $this->options['next']; } } if (!$this->hasMore) { return $this->getDisabledTextWrapper($text); } $url = $this->url($this->currentPage() + 1); return $this->getPageLinkWrapper($url, $text); } protected function getSimplePreviousButton($text = "") { if (empty($text)) { if (empty($this->options['prev'])) { $text = "←"; } else { $text = $this->options['prev']; } if (!empty($this->options['simple_prev'])) { $text = $this->options['simple_prev']; } } $nowpage=$this->currentPage() - 1; if ($this->currentPage() <= 1) { return '<a href="javascript:;" class="layui-laypage-prev layui-disabled" data-page="0">' . $text . '</a>'; } $url = $this->url( $this->currentPage() - 1 ); return '<a href="' . htmlentities($url) . '" class="layui-laypage-prev" data-page="'.$nowpage.'">' . $text . '</a>'; } protected function getSimpleNextButton($text = '') { if (empty($text)) { if (empty($this->options['next'])) { $text = "→"; } else { $text = $this->options['next']; } if (!empty($this->options['simple_next'])) { $text = $this->options['simple_next']; } } $nowpage=$this->currentPage() + 1; if (!$this->hasMore) { return '<a href="javascript:;" class="layui-laypage-next layui-disabled" data-page="'.$nowpage.'">' . $text . '</a>'; } $url = $this->url($this->currentPage() + 1); return '<a href="' . htmlentities($url) . '" class="layui-laypage-next" data-page="'.$nowpage.'">' . $text . '</a>'; } protected function getLinks() { if ($this->simple) return ''; $block = [ 'first' => null, 'slider' => null, 'last' => null ]; $side = 2; $window = $side * 2; if ($this->lastPage < $window + 6) { $block['first'] = $this->getUrlRange(1, $this->lastPage); } elseif ($this->currentPage <= $window) { $block['first'] = $this->getUrlRange(1, $window + 2); $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); } elseif ($this->currentPage > ($this->lastPage - $window)) { $block['first'] = $this->getUrlRange(1, 2); $block['last'] = $this->getUrlRange($this->lastPage - ($window + 0), $this->lastPage); } else { $block['first'] = $this->getUrlRange(1, 2); $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side); $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); } $html = ''; if (is_array($block['first'])) { $html .= $this->getUrlLinks($block['first']); } if (is_array($block['slider'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($block['slider']); } if (is_array($block['last'])) { $html .= $this->getDots(); $html .= $this->getUrlLinks($block['last']); } return $html; } public function render() { if ($this->hasPages()) { $request = request(); if ($this->simple || $request->isMobile()) { return sprintf( '%s %s', $this->getSimplePreviousButton(), $this->getSimpleNextButton() ); } else { return sprintf( '%s %s %s', $this->getPreviousButton(), $this->getLinks(), $this->getNextButton() ); } } } protected function getAvailablePageWrapper($url, $page) { return '<a href="' . htmlentities($url) . '" data-page="'.$page.'">'.$page.'</a>'; } protected function getDisabledTextWrapper($text) { return '<span class="layui-laypage-spr">'.$text.'</span>'; } protected function getActivePageWrapper($text) { return '<span class="layui-laypage-curr"><em class="layui-laypage-em" style="background-color:#1E9FFF;"></em><em>'.$text.'</em></span>'; }
3、模板中如何使用?
<ul class="layui-box layui-laypage layui-laypage-molv"> <page/> </ul>
4、效果图
0.话题发布后没及时显示,请联系官方QQ群管理;
1.话题支持代码,qq截屏直接粘贴,和QQ群一样;
2.问题描述清,比如服务器版本,程序版本;
3.能上代码,就不用文字;
4.把问题发到话题后再发QQ群;
5.如果感觉回复者解答的不错,可以发红包!
6.多帮助别人也是对自己的锻炼!
7.付费讨论中只有提问者和付费用户才可以查看回复
1.评论积分+1;每天最多10次奖励
2.发布话题积分+1;每天最多5次奖励
3.垃圾评论积分-500;
4.黄色,暴力,违反我国法律评论直接封号