Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

NextSibling and Page Collections

Started by Muut Archive 10 years ago · 1 replies · 792 views
10 years ago

I've been trying to get my page collections to work but I just cannot get it right.
Basically I just want a simple Next/Previous navigation on my article headers.

I found the example on GitHub. All of my articles are assigned the same taxonomy (category: blog). I also double checked and made sure category was defined in my site.yaml file.

In my header.html.twig file I copied the example exactly:

{% set progress = page.collection({'items':{'@taxonomy':{'category': 'docs'}},'order': {'by': 'default', 'dir': 'asc'}}) %}

{% if not progress.isFirst(page.path) %}
<a class="nav nav-prev" href="{{ progress.nextSibling(page.path).url }}">Next</a>
{% endif %}

TWIG
{% if not progress.isLast(page.path) %}
    <a class="nav nav-next" href="{{ progress.prevSibling(page.path).url }}">Previous</a>
{% endif %}

It just refused to work and I'm stumped. The links will only have urls for the current page. I know it's probably really simple, but I'm new to this and have hit a wall. Any help is much, much appreciated. Thanks!

10 years ago

Nevermind figured it out. Just forgot to change the category name to 'blog'.

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 672 1 week ago
Archive · by Deleted User, 9 years ago
0 3042 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5336 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago