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

Report an error? Manual pagination fix

Started by Muut Archive 9 years ago · 2 replies · 538 views
9 years ago

Is there a place where I can report errors? Or at least what I think is an error.

I was having trouble getting pagination to show up on my blog page. For reference, this is my setup. My 'blog' page is called 'content'; folder name is 02.content, with content.md and content.html.twig files. It is located at mysite.com/content. Also for reference, I am using a custom theme and I'm porting a custom static html site into grav. This is what I have in the frontmatter of content.md

YAML
title: Content

content:
    items: '@self.children'
    order:
        dir: desc
        by: date
    limit: 5
    pagination: true
pagination: true

In content.html.twig I replaced the previous custom pagination with the following code

TWIG
{% if config.plugins.pagination.enabled and collection.params.pagination %}
   {% include 'partials/pagination.html.twig' with {'base_url':page.url, 'pagination':collection.params.pagination} %}
{% endif %}

This code does not work. The pagination simply does not show up. I used the developer tools in safari to check the html of the page. It simply never rendered. It wasn't in the html at all.

While testing, I removed collection.params.pagination from the twig if statement {% if config.plugins.pagination.enabled and collection.params.pagination %}. This worked. The pagination shows up on the page now and it works perfectly.

I believe the if statement with collection.params.pagination will check if the current collection has pagination enabled, which is does, right? Pagination is enabled both in the plugin's setting yaml file and in content.md.

Everything works now, so I don't really have a question. But I thought I would bring this up to the rest of the community incase someone else had the same problem :^)

9 years ago

Maybe it is because collection has to be set before with

TWIG
{% set collection = page.collection() %}

Does it work like that?

9 years ago

The collection was declared at the top of the page, before the pagination code.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1328 9 years ago
Archive · by Muut Archive, 9 years ago
2 921 9 years ago
Archive · by Muut Archive, 9 years ago
2 4050 9 years ago
Archive · by Muut Archive, 9 years ago
1 2928 9 years ago
Archive · by Muut Archive, 9 years ago
3 1107 9 years ago