laravel修改分页样式并且把«和»改成上一页下一页
Song •
4344 次浏览 •
0个评论 •
2017年10月21日
在laravel中,默认的«和»确实看起来比较不好看,有时候我们需要把他们替换成中文的上一页下一页?其实很方便,最近有几个人问我,所以我整理一下发出来,当然这不是唯一的解决办法哈,但是它确实能解决问题。
laravel5.3以下修改办法
1、找到文件/vendor/laravel/framework/src/Illuminate/Pagination/BootstrapThreeNextPreviousButtonRendererTrait.php,打开以后把代码改成如下所示:
<?php
namespace Illuminate\Pagination;
trait BootstrapThreeNextPreviousButtonRendererTrait
{
/**
* Get the previous page pagination element.
*
* @param string $text
* @return string
*/
public function getPreviousButton($text = '上一页')
{
// If the current page is less than or equal to one, it means we can't go any
// further back in the pages, so we will render a disabled previous button
// when that is the case. Otherwise, we will give it an active "status".
if ($this->paginator->currentPage() <= 1) {
return $this->getDisabledTextWrapper($text);
}
$url = $this->paginator->url(
$this->paginator->currentPage() - 1
);
return $this->getPageLinkWrapper($url, $text, 'prev');
}
/**
* Get the next page pagination element.
*
* @param string $text
* @return string
*/
public function getNextButton($text = '下一页')
{
// If the current page is greater than or equal to the last page, it means we
// can't go any further into the pages, as we're already on this last page
// that is available, so we will make it the "next" link style disabled.
if (! $this->paginator->hasMorePages()) {
return $this->getDisabledTextWrapper($text);
}
$url = $this->paginator->url($this->paginator->currentPage() + 1);
return $this->getPageLinkWrapper($url, $text, 'next');
}
}
好了,现在刷新一下我们的分页,看看是不是变成上一页下一页了?
laravel 5.3以上修改方法
其实修改方法一样,只是文件位置不同了,我查看5.5的位置为resources/views/vendor/pagination/default.blade.php,只需要在这里修改即可。
相对来说5.3以上配置更加方便。
-
Mac上通过brew安装lnmp (php7)开发环境并且搭建laravel项目 2017-10-21 -
laravel把实现数组和对象的相互转化以及toArray() 的用法 2017-10-20 -
laravel操作Redis排序/删除/列表/随机/Hash/集合等方法全解 2017-10-14 -
laravel5中间件的使用方法以及如何自定义中间件 2017-10-12 -
laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误 2017-10-11

更多相关好文