Adding the previous and next links to the blog articles in Joomla, Wordpress and various other php-based blog articles seems quite easy. However, how can I add such a feature to my Voog website? I looked around in their developers documentation but didn’t find any information.
Asked
Active
Viewed 131 times
2 Answers
3
It's now possible with latest Voog update. See docs.
Source from Voog developers documentation:
Previous (older) article
{% if article.older %}
<a href="{{ article.older.url }}">{{ article.older.title }}</a>
{% endif %}
Next (newer) article
{% if article.newer %}
<a href="{{ article.newer.url }}">{{ article.newer.title }}</a>
{% endif %}

Rene Korss
- 5,414
- 3
- 31
- 38
0
Currently, there is no direct way to fetch the previous and/or next articles, but it's easily achievable with this code:
first we have to find the current article to get the previous and next ones
{% for blog_article in blog.articles %}
{% if article.id == blog_article.id %}
note that blog.articles is sorted newest-first, so the next article actually comes before the previous one
{% assign next_article_idx = forloop.index0 | minus: 1 %}
{% assign prev_article_idx = forloop.index0 | plus: 1 %}
{% endif %}
{% endfor %}
then, cycle through the articles once more and fetch the previously found articles
{% for blog_article in blog.articles %}
{% if prev_article_idx == forloop.index0 %}
<a class="prev" href="{{ blog_article.url }}">{{ blog_article.title }}</a>
{% endif %}
{% if next_article_idx == forloop.index0 %}
<a class="next" href="{{ blog_article.url }}">{{ blog_article.title }}</a>
{% endif %}
{% endfor %}
The article page footer in the Anchorage template is a bit more advanced, but uses the same method — you can see the code here.

mikkpr
- 7
- 3

Mathias-Erik Tempel
- 20
- 3