首页 文章

在Laravel中附加分页链接URL

提问于
浏览
0

我该如何追加:

#products

在Laravels分页链接方法使用的分页URL的末尾,所以我可以在地址栏中获得以下内容?:

products?page=3#products

这样我的移动用户和具有低分辨率桌面的人不必在每次使用分页链接导航时向下滚动页面 .


这是我在配置/视图中的内容:

/*
    |--------------------------------------------------------------------------
    | Pagination View
    |--------------------------------------------------------------------------
    |
    | This view will be used to render the pagination link output, and can
    | be easily customized here to show any view you like. A clean view
    | compatible with Twitter's Bootstrap is given to you by default.
    |
    */

    'pagination' => 'products.ProductPresenter',

我得到了:

Method Illuminate\View\View::__toString() must not throw an exception

根据Laravel文档我的演示者:

class ProductPresenter extends Illuminate\Pagination\Presenter {

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

    public function getDisabledTextWrapper($text)
    {
        return '<li class="unavailable"><a href="">'.$text.'</a></li>';
    }

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

}

1 回答

  • 0

    使用 fragment()

    {{$products->fragment('products')->links();}}
    

相关问题