核心分页默认文件的路径:tp5\thinkphp\library\think\paginator\driver\Bootstrap.php
对应的上一个方法名:
/**
* 上一页按钮
* @param string $text
* @return string
*/
protected function getPreviousButton($text = "«")
{
}
/**
* 下一页按钮
* @param string $text
* @return string
*/
protected function getNextButton($text = '»')
{
详细略
}
提示:你可以直接设置$text="默认值为上一篇/下一篇",但是这样就写死了,我们希望通过视图的方式直接修改上一篇或者下一篇的具体内容。
视图代码:
{$list->render("上一个","下一个")} ;//注意,默认这样传值是不对的,我们还需要按如下流程操作。
在tp5\thinkphp\library\think\paginator\driver\Bootstrap.php 文件中
搜索: public function render()
修改:
public function render($a="",$b="")
{
if ($this->hasPages()) {
if ($this->simple) {
return sprintf(
'<ul class="pager">%s %s</ul>',
$this->getPreviousButton($a),
$this->getNextButton($b)
);
} else {
return sprintf(
'<ul class="pagination">%s %s %s</ul>',
$this->getPreviousButton($a),
$this->getLinks(),
$this->getNextButton($b)
);
}
}
}