0
votes

How can I append:

#products

To the end of the pagination URL used by Laravels pagination links method so I could get the following in the address bar?:

products?page=3#products

This is so that my mobile users and people with low resolution desktops don't have to scroll down the page every time they navigate using the pagination links.


This is what I have in my config/view:

/*
    |--------------------------------------------------------------------------
    | 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',

And I'm getting:

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

My presenter as per Laravel documentation:

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
To change the pagination being generated by Laravel by making your own Custom Presenter.Bogdan
@Bogdan I followed that but I'm getting 'No hint path defined for [ProductPresenter]' :(imperium2335
Please post the code you're using.Bogdan
@Bogdan Please see edit.imperium2335

1 Answers

0
votes

use fragment()

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