Anyone know if it's possible to check what the current field is while in a loop of a matrix block? Running into an issue with a matrix block in my loop for how I want to output the content.
{% case 'testimonials' %}
{% if block.getPrev() %}
{# if the previous block isn't the "testimonials" block start container #}
{% if block.getPrev().type != 'testimonials' %}
<div class="container-fluid add-top">
<div class="row">
<div class="text-center testimonials">
{% endif %}
{# if there isn't a previous block start a div could be the first block#}
{% else %}
<div class="container-fluid add-top">
<div class="row">
<div class="text-center testimonials">
{% endif %}
{# Output Content #}
{# Output each testimonial here #}
<blockquote class="blockquote-unstyled" style="display:none;">
<footer class="text-uppercase">
<span title="Source Title">{{block.sourceTitle}}</span>
</footer>
<p class="lead">“{{block.lead}}”</p>
</blockquote>
{% if block.getPrev().type != 'testimonials' %}
<ul class="list-inline">
{% endif %}
{# Output image for each testimonial here #}
{% set image = block.image.first() %}
<li><img class="img-responsive img-circle" alt="Profile" src="{{ image.getUrl('testimonials') }}" width="{{ image.getWidth('testimonials') }}" height="{{ image.getHeight('testimonials') }}"/></li>
{% if block.getNext().type != 'testimonials' %}
</ul>
{% endif %}
{# Output Content #}
{# if this is the "testimonials" block type #}
{% if block.type == 'testimonials' %}
{# if there is another block to check #}
{% if block.getNext() %}
{# if the next block isn't the "testimonials" block end div #}
{% if block.getNext().type != 'testimonials' %}
</div>
</div>
</div>
{% endif %}
{# if there isn't another block end a ul might be the last block#}
{% else %}
</div>
</div>
</div>
{% endif %}
{% endif %}
<!-- End Testimonials Block -->
So if I enter three testimonials I want the content to appear like this.
<blockquote class="blockquote-unstyled" style="display:none;">
<footer class="text-uppercase">
<span title="Source Title">{{block.sourceTitle}}</span>
</footer>
<p class="lead">“{{block.lead}}”</p>
</blockquote>
<blockquote class="blockquote-unstyled" style="display:none;">
<footer class="text-uppercase">
<span title="Source Title">{{block.sourceTitle}}</span>
</footer>
<p class="lead">“{{block.lead}}”</p>
</blockquote>
<blockquote class="blockquote-unstyled" style="display:none;">
<footer class="text-uppercase">
<span title="Source Title">{{block.sourceTitle}}</span>
</footer>
<p class="lead">“{{block.lead}}”</p>
</blockquote>
<ul class="list-inline">
<li><img class="img-responsive img-circle" alt="Profile" src="{{ image.getUrl('testimonials') }}" width="{{ image.getWidth('testimonials') }}" height="{{ image.getHeight('testimonials') }}"/></li>
<li><img class="img-responsive img-circle" alt="Profile" src="{{ image.getUrl('testimonials') }}" width="{{ image.getWidth('testimonials') }}" height="{{ image.getHeight('testimonials') }}"/></li>
<li><img class="img-responsive img-circle" alt="Profile" src="{{ image.getUrl('testimonials') }}" width="{{ image.getWidth('testimonials') }}" height="{{ image.getHeight('testimonials') }}"/></li>
</ul>
Before changing to use a switch I was using the following which worked great, just can't think of an equivalent for switch.
<!-- Testimonials Block -->
{% if entry.testimonials|length %}
<div class="container-fluid add-top">
<div class="row">
<div class="text-center testimonials">
{% for block in entry.testimonials %}
{% if block.type == "testimonial" %}
{% set image = block.image.first() %}
<blockquote class="blockquote-unstyled" style="display:none;">
<footer class="text-uppercase">
<span title="Source Title">{{block.sourceTitle}}</span>
</footer>
<p class="lead">“{{block.lead}}”</p>
</blockquote>
{% endif %}
{% endfor %}
<div class="list-inline">
{% for block in entry.testimonials %}
{% if block.type == "testimonial" %}
{% set image = block.image.first() %}
<li><img class="img-responsive img-circle" alt="Profile" src="{{ image.getUrl('testimonials') }}" width="{{ image.getWidth('testimonials') }}" height="{{ image.getHeight('testimonials') }}"/></li>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}