Home  >  Article  >  Backend Development  >  laravel怎么改造分页类,给他加上首页和尾页

laravel怎么改造分页类,给他加上首页和尾页

WBOY
WBOYOriginal
2016-06-06 20:39:13920browse

求助laravel的分页类该怎么改造下。可以生成有首页,尾页,有总计多少条记录,当前第几页,分页,

回复内容:

求助laravel的分页类该怎么改造下。可以生成有首页,尾页,有总计多少条记录,当前第几页,分页,

可以考虑扩展Illuminate\Pagination\Presenter和添加分页模版。
目前我就是这样做的:

<code>class ExtPresenter extends Illuminate\Pagination\Presenter{

    public function getActivePageWrapper($text)
    {
        return '<span class="current">'.$text.'</span>';
    }

    public function getDisabledTextWrapper($text)
    {
        return '<span class="ellipsis">'.$text.'</span>';
    }

    public function getPageLinkWrapper($url, $page,$rel = null)
    {
        return '<a href="'.%24url.'">'.$page.'</a>';
    }

}
</code>

分页模版

<code><?php $presenter = new ExtPresenter($paginator);
?>

<?php if ($paginator->getLastPage() > 1): ?>
    <div class="cms_page">
        <?php echo $presenter->render(); ?>
    </div>
<?php endif; ?>
</code>

抱歉,上面代码好像没回答你问题重点上,如何加上首页与尾页,可以考虑参阅下面文章:
http://php2012web.blog.51cto.com/5585213/1539601

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn