Last active
January 20, 2016 22:25
-
-
Save a-am/81385d0254d25d9cea55 to your computer and use it in GitHub Desktop.
Pagination with Venti events.ds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set today = now %} | |
{% set total = craft.venti.allEvents().startDate('and', '>= ' ~ today).total() %} | |
{% set limit = 5 %} | |
{% set prev = 1 %} | |
{% set next = 2 %} | |
{% set pge = craft.request.getParam('pg') ? craft.request.getParam('pg') : 0 %} | |
{% set lastPage = "" %} | |
{% set offset = (pge - 1) * limit %} | |
{% if total % limit == 0 %} | |
{% set lastPage = (total // limit) %} | |
{% else %} | |
{% set lastPage = (total // limit) + 1 %} | |
{% endif %} | |
{% if pge - 1 <= 0 %} | |
{% set prev = 0 %} | |
{% set next = 2 %} | |
{% elseif pge == lastPage %} | |
{% set prev = pge - 1 %} | |
{% set next = lastPage %} | |
{% else %} | |
{% set prev = pge - 1 %} | |
{% set next = pge + 1 %} | |
{% endif %} | |
{% set events = craft.venti.allEvents().startDate('and', '>= ' ~ today).limit(limit).offset(offset).find() %} | |
{# Now use events in for loop to create list #} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment