I have a Paragraph type 'Call to action' with one link field field_link
.
I have another Paragraph type where I call the 'Call to action' paragraph as an Entity reference revisions
field. With Allowed number of values
set to 2.
So the editor is able to insert two Call to action links.
I want to attach 2 specific CSS classes to both links:
On the first link:
<a href="" class="button-one">Button one</a>
On the second link:
<a href="" class="button-two">Button two</a>
How do I loop through, so I am able to attach different classes?
Update:
In paragraph--call-to-action.html.twig
I added:
{% block paragraph %}
{% for item in content.field_link %} {% if loop.index == 1 %} Button one {% elseif loop.index == 2 %} Button two {% endif %} {% endfor %}
{% endblock paragraph %}
But now it's rendering always the 2 buttons? What's wrong here?