Any examples of numeric pagination?

Jeremiah: 2 weeks ago

I can find examples of prev/next style pagination but none of creating proper numeric-style pagination (eg. how Google do it).

Does anyone have an example I could use?

Elijah: 2 weeks ago


{% paginate craft.entries.section('blog').limit(10) as entries %}
    <a href="{{ paginate.firstUrl }}">First Page</a>
    {% if paginate.prevUrl %}<a href="{{ paginate.prevUrl }}">Previous Page</a>{% endif %}

    {% for page, url in paginate.getPrevUrls(5) %}
        <a href="{{ url }}">{{ page }}</a>
    {% endfor %}

    <span class="current">{{ paginate.currentPage }}</span>

    {% for page, url in paginate.getNextUrls(5) %}
        <a href="{{ url }}">{{ page }}</a>
    {% endfor %}

    {% if paginate.nextUrl %}<a href="{{ paginate.nextUrl }}">Next Page</a>{% endif %}
    <a href="{{ paginate.lastUrl }}">Last Page</a>

This outputs something along the lines of: First Page, Previous Page, (nearby page numbers), Next Page, Last Page