This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

mattm
mattm

I use a Scope to filter database results form URL Parameter. I'm not using the Record List feature.
This example returns a list of image names from the nature category.

But how do I paginate the results?

Edit:
I got page numbers to show using this, but clicking one does not go to the next page.

$this->page["scopeCategory"] = Gallery::applyCategory($category)->paginate(15);

URL
localhost/nature

Identifiers
/:category?latest/:page?

Model

Scope

public function scopeApplyCategory($query, $category = null) {
    return $query->where('category', $category);
}

Page

Code

# Get URL Category Identifer
$category = $this->param('category');

# Create Twig Variable from Scope Apply
$this->page["scopeCategory"] = Gallery::applyCategory($category)->get();

Markup

<!-- Set Scope Variable -->
{% set scopeCategory = this.page.scopeCategory %}

<!-- List of Image Names filtered by Scope -->
{% for image in scopeCategory %}            
    {{ image.name }}
{% endfor %}

<!-- Pagination Here -->

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.