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

Pagination on category: pages?

Started by Muut Archive 12 years ago · 4 replies · 902 views
12 years ago

When I first hit a page like http://192.168.33.10/tag:grav I get pagination that makes sense. In this case, two pages. But when I click on a pagination arrow or page number, I end up at a page like http://192.168.33.10/page:2 which loses the important tag: part.

What is the right way to do pagination on a category: or tag: page?

12 years ago

Is your pagination plugin up to date? That was a problem a long time ago, but has been fixed for a while. Also ensure your pagination twig looks correct too:

TWIG
<p class="prev-next">
{% if not page.isFirst %}
  <a class="button" href="{{ page.nextSibling.url }}"><i class="fa fa-chevron-left"></i> Next Post</a>
{% endif %}

{% if not page.isLast %}
  <a class="button" href="{{ page.prevSibling.url }}">Previous Post <i class="fa fa-chevron-right"></i></a>
{% endif %}
</p>

You can see this in action on the Grav blog:

http://getgrav.org/blog/tag:release

Click "Page 2"

12 years ago

bin/gpm update says I don't need to update pagination.

But my pagination.html.twig looks like it's going to need an overhaul. My previous and next code is wrong (old).

Is this still right for the pages numbers?

TWIG
{% for page in pagination %}
    {% if page.isCurrent %}
        <span>{{ page.number }}</span>
    {% else %}
        <a href="{{ base_url }},{{ page.url }}">{{ page.number }}</a>
    {% endif %}
{% endfor %}

I need to go back to Antimatter and look there, I suppose.

12 years ago

Actually, my mistake.. that is the wrong code i pasted.. should of been:

TWIG
    {% block pagination %}
        {% if collection.params.pagination %}
        {% include 'pagination.html.twig' with {'pagination':collection.params.pagination} %}
        {% endif %}
    {% endblock %}

in the blog.html.twig file.

Also Pagination plugin is currently 1.2.1

12 years ago

OK, I've got it now. It needed the {{ pagination.params }} part as shown in the current pagination plugin's template file.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1981 9 years ago
Archive · by Muut Archive, 9 years ago
2 1336 9 years ago
Archive · by Muut Archive, 9 years ago
2 4536 9 years ago
Archive · by Muut Archive, 9 years ago
1 3391 9 years ago
Archive · by Muut Archive, 9 years ago
3 1486 9 years ago