Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit amount of links shown with Laravel pagination

Any easy way to limit how many links are shown with Laravels pagination?

Currently it shows 13 links at most (Prev, 1 2 3 4 5 7 8 .. 78 79 next)

This however is too much for mobile devices and becomes a two line navigation... is there any way to set the links to e.g. only show 10?

I have messed around with the pagination presenter but nothing actually seemed to work.

Thanks

like image 991
Lovelock Avatar asked Dec 26 '14 10:12

Lovelock


1 Answers

I used css to limit the links that I allowed. Really simple.. this can be extended to show any number of pages, at any number of breakpoints

@media screen and ( max-width: 400px ){      li.page-item {          display: none;     }      .page-item:first-child,     .page-item:nth-child( 2 ),     .page-item:nth-last-child( 2 ),     .page-item:last-child,     .page-item.active,     .page-item.disabled {          display: block;     } } 

this specific implementation allows the arrows, the '...', the first page, active page and last page

like image 131
Erik White Avatar answered Oct 11 '22 14:10

Erik White