Hey, does anyone know how to implement a Next Article or Previous Article within the Blog Module?
So, for instance, you are on the Blog Article Detail page, on the bottom of the page it shows ‘View Previous Article’ or ‘View Next Article’.
I know I did this in BC, but for the life of me, can’t quite figure out why it isn’t working in Treepl.
I’m sure I’ll be able to figure it out, but if anyone has a quick solution, I’d be much obliged.
This is what I have tried, but it doesn’t seem to work (modified from my info from BC):
{% component source: “Work”, layout: “”, object: “collection”, collectionVariable: “paginationData”, type: “module” %}
{% for item in paginationData.items -%}
{% if item.Id == Id -%}
{% assign currentLoopIndex = forloop.index0 -%}
{% break -%}
{% endif -%}
{% endfor -%}
{% if currentLoopIndex -%}
{% assign prevLoopIndex = currentLoopIndex | minus: 1 -%}
{% assign prevUrl = paginationData.items[prevLoopIndex].url -%}
{% assign prevName = paginationData.items[prevLoopIndex].name -%}
{% endif -%}
{% if currentLoopIndex < paginationData.items | size | minus: 1 -%}
{% assign nextLoopIndex = currentLoopIndex | plus: 1 -%}
{% assign nextUrl = paginationData.items[nextLoopIndex].url -%}
{% assign nextName = paginationData.items[nextLoopIndex].name -%}
{% endif -%}
Thanks,
Aaron