Skip to content

Instantly share code, notes, and snippets.

@ChVuagniaux
Created November 23, 2017 08:28
Show Gist options
  • Save ChVuagniaux/63b319b70537298c9e6dc067051b9acc to your computer and use it in GitHub Desktop.
Save ChVuagniaux/63b319b70537298c9e6dc067051b9acc to your computer and use it in GitHub Desktop.
OctoberCMS blog pagination that use "/post" instead of "/posts/1"
{% if posts.lastPage > 1 %}
<ul class="pagination">
{% if posts.currentPage > 1 %}
{% if (posts.currentPage == 2) %}
<li><a href="{{ listPage|page({ (pageParam): null }) }}">&larr; </a></li>
{% else %}
<li><a href="{{ listPage|page({ (pageParam): (posts.currentPage - 1) }) }}">&larr; </a></li>
{% endif %}
{% endif %}
{% for page in 1..posts.lastPage %}
{% if (page == 1) %}
<li class="{{ posts.currentPage == page ? 'active' }}">
<a href="{{ listPage|page({ (pageParam): null }) }}">{{ page }}</a>
</li>
{% else %}
<li class="{{ posts.currentPage == page ? 'active' }}">
<a href="{{ listPage|page({ (pageParam): page }) }}">{{ page }}</a>
</li>
{% endif %}
{% endfor %}
{% if posts.lastPage > posts.currentPage %}
<li><a href="{{ listPage |page({ (pageParam): (posts.currentPage + 1) }) }}"> &rarr;</a></li>
{% endif %}
</ul>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment