1

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.

2 Answers 2

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 %}
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.