Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Content & Markdown

Displaying Pagination with on Page Twig and HTML

Started by T. H. Wright 9 years ago · 0 replies · 1050 views
9 years ago

My site's homepage runs the following collection to display recent posts. How do I display the option to cycle forward and backward through the collection of recent posts?

Do I need a different Twig function that makes a call to the collection?

TWIG
{% set options = { items: {'@taxonomy.category': 'post'}, 'limit': 9, 'order': {'by': 'date', 'dir': 'desc'}, 'pagination': true } %}
{% set recent_posts = page.collection(options) %}

<ul>
    {% for p in recent_posts %}
    <li class="recent-posts" style="list-style: none"><strong><a href="{{ p.url }}">{{ p.title }}</a></strong><br>
        <span>{{ p.date|date("D, F d, Y") }} T{{ p.date|date("H:i:s A T") }}</span></li>
    {% endfor %}
</ul>

Suggested topics

Topic Participants Replies Views Activity
Content & Markdown · by Jochen, 8 months ago
6 96 8 months ago
Content & Markdown · by Ton Haarmans, 1 year ago
10 184 1 year ago
Content & Markdown · by Jan L'Am, 1 year ago
4 147 1 year ago
Content & Markdown · by Leonardo, 1 year ago
3 61 1 year ago
Content & Markdown · by belthasar, 1 year ago
4 255 1 year ago