BartHuis's avatar

paginator link to page-3 instead of ?page=3

Hi,

I can't find anything on this topic, while i think more people want this.

Is there a pre made way to change the pagination to page-3 instead of ?page=3 so domain.com/products/page-3

Or do i have to make this myself in the router?

Bart

0 likes
4 replies
d3xt3r's avatar

Query strings are not considered when matching routes, so you will have to modify the routes to accept additional optional url segment ... and take decisions accordingly ...

BartHuis's avatar

I think our friends from spatie allready made it, just asked them if i can easily change page/1 to page-1, but i think it can ;) https://packagist.org/packages/spatie/laravel-paginateroute

it say's:

If you want to customize or add translations for the "page" url segment, you can publish the language files.

$ php artisan vendor:publish --provider="Spatie\PaginateRoute\PaginateRouteServiceProvider"

d3xt3r's avatar

Oh, i didn't realise you were looking for packages ;) pre made missed it :(

BartHuis's avatar

@d3xt3r actually i was looking for a way just like the $paginatedobject->setPath() function.

I thought maybe there was something like:

$paginatedobject->setVariableInput('parameter')

$paginatedobject->setVariableInput('path')

but there isn't :( actually, for who's coming here by google, this example is just dummy code and doesn't excist (jet). the package bij spatie is also not able to handle the - instead of / , they can make it for me, but i allready looked at the package, i think i'll try it myself ;)

Bart

Please or to participate in this conversation.