Skip to content

Instantly share code, notes, and snippets.

@piotrpog
Created May 10, 2019 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrpog/dc740c96b0ab2cdecbae9b3092950e05 to your computer and use it in GitHub Desktop.
Save piotrpog/dc740c96b0ab2cdecbae9b3092950e05 to your computer and use it in GitHub Desktop.
Pagination template component for Craft CMS. List of pages is rendered using <select> HTML element. More info: http://craftsnippets.com/articles/ellipsis-pagination-component-for-craft-cms
{# settings #}
{% set info = pageInfo %}
{# logic #}
{% if info.totalPages > 1 %}
<select name="" id="" onchange="document.location.href = this.options[this.selectedIndex].value;">
{% for link in info.getRangeUrls( 1, info.totalPages ) %}
<option value="{{link}}" {{info.currentPage == loop.index ? 'selected="selected"'}}>{{'page'|t}} {{loop.index}}</option>
{% endfor %}
</select>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment