Php 附加到Laravel中的分页链接URL

Php 附加到Laravel中的分页链接URL,php,laravel,laravel-4,pagination,Php,Laravel,Laravel 4,Pagination,如何附加: #products 到Laravels pagination links方法使用的分页URL的末尾,以便在地址栏中获得以下内容: products?page=3#products 这样,我的移动用户和低分辨率桌面用户就不必每次使用分页链接导航时都向下滚动页面 这是我的配置/视图中的内容: /* |-------------------------------------------------------------------------- | Paginat

如何附加:

#products
到Laravels pagination links方法使用的分页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>';
    }

}
class ProductPresenter\Pagination\Presenter{
公共函数getActivePageWrapper($text)
{
返回“
  • ”; } 公共函数getDisabledTextWrapper($text) { 返回“
  • ”; } 公共函数getPageLinkWrapper($url,$page,$rel=null) { 返回“
  • ”; } }
    使用
    fragment()


    通过创建您自己的来更改Laravel生成的分页。@Bogdan我遵循了这一点,但我得到的是“没有为[ProductPresenter]定义提示路径”:(请发布您正在使用的代码。@Bogdan请查看编辑。以上是您的问题的答案。如果您有多个问题,请在不同的问题中发布。这样会更容易回答。顺便问一下,您是如何输出演示者的?抱歉,我以为您的答案将与自定义演示者的内容一起使用。这很有效:)
    {{$products->fragment('products')->links();}}