andru26
3/31/2017 - 12:23 AM

Article Next/Prev Navigation

Article Next/Prev Navigation

<footer class="article-footer">

  {% for kb_article in topic.articles %}
    {% if kb_article.id == article.id %}
      
      {% assign curr_article_index = forloop.index %}
      {% assign prev_article_index = forloop.index | minus:1 %}
      {% assign next_article_index = forloop.index | plus:1 %}

    {% endif %}
  {% endfor %}

  {% for kb_article in topic.articles %}
    
    {% if forloop.index == prev_article_index and prev_article_index != 0 %}
      <h4>Previous article: <a href="{{kb_article.public_url}}">{{kb_article.subject_plain}}</a></h4>
    {% endif %}

    {% if forloop.index == next_article_index and next_article_index <= forloop.length %}
      <h4>Next article: <a href="{{kb_article.public_url}}">{{kb_article.subject_plain}}</a></h4>
    {% endif %}

  {% endfor %}

  <h4>Back To: <a href='{{ topic.public_articles_url }}'>{{ topic.name }}</a></h4>

</footer>