This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I have a galley with categories and image records.
I'm trying to get the :category
Identifier nature
from the URL to filter database results.
Problem
The code returns the nature images and displays pagination.
But when I click a page number the url changes to ?page=2
or /2
, but the page button stays on 1
and the images don't change.
October
URL
localhost/gallery/nature
Identifiers
/gallery/:category?latest/:page?
Laravel
Get all image records in category nature
.
I put this in the Code section of the Page.
$category = $this->param('category');
$this['scopeCategory'] = Gallery::where('category', $category)->paginate(5);
Twig
Display the images with pagination.
List Images
{% for image in scopeCategory %}
<img src="example.com/{{ image.name }}.jpg">
{% endfor %}
Pagination
<< 1 | 2 | 3 | 4 >>
{{ scopeCategory.render|raw }}
Last updated
Have you tried to include page number in query manually?
->paginate($perPage, $page)
And maybe dump current page number to be sure it is correctly taken from URL.
1-2 of 2