Very new to Craft & Twig. So I get the following error: Impossible to invoke a method ("url") on a integer variable ("0") with the below code:
{% if module.type == "rotator" %}
<div class="rotator">
{% for row in module.contents %}
{% set position = loop.index0 %}
{% set previous = loop.index -1 %}
{% set next = loop.index + 1 %}
<div class="rotator__item active">
<img src="{{ row.slideImage.first().url}}" alt="slideImage.title">
</div>
<div class="switcher">
<span class="rotator__control left">
<a href="{{ previous.url() }}"> ‹</a>
</span>
<span class="previous__title">
{{ previous.slideTitle }}
</span>
<div class="divider">
</div>
<span class="content">
<p>{{row.slideTitle}}</p>
<a href="row.slideImage.first().url">
{{row.slideCaption}}
</a>
</span>
<span class="rotator__control right">
{{ next.slideTitle }}
<span>
<a href="{{ next.url() }}"> ›</a>
</span>
</div>
{% endfor %}
</div>
{% endif %}
So basically I need a 'previous' and 'next' variable that corresponds to the previous row and the next row in the Super Table. Essentially I need a way to call the current row in the Super Table I'm at, and the previous row and next row relative to the row I'm on.
Here's what my set up looks like:
I've tried loop.index0 + 1 and loop.index + 1. But neither work and I know I am calling them in the wrong way.