1

I'm not clear on how I would iterate over a Matrix field to be able to include the content in the row.

Wish there was an example in the docs: https://sprout.barrelstrengthdesign.com/docs/reports/custom-twig-template-report.html#template-settings

{% for entry in entries %}

    {% do craft.sproutReports.addRow([
      entry.title, 
      entry.myMatrixField
    ]) %}

{% endfor %}
2

I got it to work with this code:

{% for entry in entries %}

    {% set myArray = [entry.title] %}

    {% for block in entry.myMatrixField %}

        {% set myArray = myArray|merge([block.field1,block.field2,block.field3]) %}  

    {% endfor %}

    {% do craft.sproutReports.addRow(myArray) %}

{% endfor %}
-1

Try the below code

{% for block in entry.myMatrixField %}
  {% if block.type == "sproutReports" %}
    <blockquote class="sproutReports{{ loop.index }}">
      <p>{{ block.sproutReports}}</p>
    </blockquote>
  {% endif %}
{% endfor %}
  • My question was specific to Sprout Reports plugin. – SoHo May 7 at 22:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.