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

NextSibling and Page Collections

Started by Muut Archive 9 years ago · 1 replies · 604 views
9 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!

9 years ago

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

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1323 9 years ago
Archive · by Muut Archive, 9 years ago
2 920 9 years ago
Archive · by Muut Archive, 9 years ago
2 4048 9 years ago
Archive · by Muut Archive, 9 years ago
1 2924 9 years ago
Archive · by Muut Archive, 9 years ago
3 1106 9 years ago