3

I have several reports to create but their settings are going to be very similar. So I want to use one settings.twig for all of them and detect which report is the current one to show any extra settings.

Something like this pseudo code:

<div><!--common field--></div>
<div><!--common field--></div>
<div><!--common field--></div>
{% set current_report = craft.barrelstrength.sproutreports.current %}
{% if current_report == 'fourth_quarter_payments' %}
  <div><!--some field--></div>
{% elseif current_report == 'payments_above_100' %}
  <div><!--some field--></div>
{% endif %}

Is it possible to know what the current report is so conditionals can be used in the settings template?

1

At the time of this post, the only variable available to the settings template that might help you out is the settings object: {{ dump(settings) }}.

As this is the Twig Template report, you might be able to use the settings.resultsTemplate value to identify the active report in a shared settings file.


I've opened a ticket for adding improved support for this scenario and will look into making the dataSource object available to the settings template in a coming release.

1
  • 1
    settings.resultsTemplate is what I was looking for. Thanks!
    – Sheldon
    Mar 15 at 21:18

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.