Ad

How To Add Pagination In A List On A Frontend View?

- 1 answer

In octoberCMS, how do I paginate a list with hundreds of items and display pagination elements?

Ad

Answer

In your component (this is like a controller) get all Users in chunks of 15 per page and pass them to your page view:

$users = User::paginate(15);
$this->page['users'] = $users;

In your view render a list and below the pagination-links (automatically!).

<div class="container">
    {% for user in users %}
        {{ user.name }}
    {% endfor %}
</div>

{{ users.render|raw }} // This renders pagination links
Ad
source: stackoverflow.com
Ad