由于tp5自带分页实在是不好看,所以就很想自定义一个分页,啥也不说了,直接上代码:
1.在tp5框架目录下找到extend文件夹,并创建page文件夹,在page文件夹下中创建Page.php类文件:(下图为tp5框架目录)
2、然后复制下面的代码,当然要是你觉得还是不好看的话,你也可以修改一下。
<?php // +---------------------------------------------------------------------- // | Description: 自定义分页 // +---------------------------------------------------------------------- // | Author: phpAndy <383916522@qq.com> // +---------------------------------------------------------------------- namespace page; use think\Paginator; class Page extends Paginator { //首页 protected function home() { if ($this->currentPage() > 1) { return "<a href='" . $this->url(1) . "' title='首页'>首页</a>"; } else { return "<p>首页</p>"; } } //上一页 protected function prev() { if ($this->currentPage() > 1) { return "<a href='" . $this->url($this->currentPage - 1) . "' title='上一页'>上一页</a>"; } else { return "<p>上一页</p>"; } } //下一页 protected function next() { if ($this->hasMore) { return "<a href='" . $this->url($this->currentPage + 1) . "' title='下一页'>下一页</a>"; } else { return"<p>下一页</p>"; } } //尾页 protected function last() { if ($this->hasMore) { return "<a href='" . $this->url($this->lastPage) . "' title='尾页'>尾页</a>"; } else { return "<p>尾页</p>"; } } //统计信息 protected function info(){ return "<p class='pageRemark'>共<b>" . $this->lastPage .