Skip to content

Instantly share code, notes, and snippets.

@rruhlen
Last active January 1, 2016 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rruhlen/8190270 to your computer and use it in GitHub Desktop.
Save rruhlen/8190270 to your computer and use it in GitHub Desktop.
How to add "previous article" and "next article" to your Desk.com support center article pages. Allows user to cycle through all articles in current topic.
{% for current_article in topic.articles %}
{% if current_processed == true %}
{% assign next_article = current_article %}
{% assign current_processed = false %}
{% endif %}
{% if current_article.subject_plain == article.subject_plain %}
{% assign current_processed = true %}
{% assign previous_article = last_processed %}
{% endif %}
{% assign last_processed = current_article %}
{% endfor %}
<br>
<hr>
{% if previous_article %}
<a href="{{ previous_article.public_url }}" title="{{ previous_article.subject_plain }}">Previous Article</a>
{% else %}
<span style="opacity: 0.5">Previous Article</span>
{% endif %}
{% if next_article %}
<a style="float: right;" href="{{ next_article.public_url }}" title="{{ next_article.subject_plain }}">Next Article</a>
{% else %}
<span style="float: right; opacity: 0.5">Next Article</span>
{% endif %}
<hr>
<br>
@irowboat
Copy link

When the number of articles exceeds 20, any further articles have both "Next" and "Previous" links disabled (the 20th article has just "Next" disabled), so even given a link to—say—the 40th article, the "Next/Previous" links are disabled. Any help getting this to work would be appreciated.

@rruhlen
Copy link
Author

rruhlen commented Jul 20, 2015

We're aware of the 20 articles per topic limitation and have a feature request open to remove the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment