Display related table data #29
Unanswered
angieherrera
asked this question in
Q&A
Replies: 1 comment 1 reply
-
@angieherrera This is possible. Here's a very simple hard-coded example using the Twig Template Query report results template. You can, of course, loop through a set of users and call To display line breaks, you'll need to consider TWO contexts. One is the HTML rendering of your report in the CP and the other is the CSV export of your report if a content admin were to download the report. You can use {# Creates a `lineBreak` variable that can be used for HTML and CSV Export output #}
{% set lineBreak = isExport ? '\r\n' : '<br>' %}
{# Sets heading column names #}
{% do sprout.twigDataSet.addHeaderRow([
"Client",
"Tasks"
]) %}
{# Add a row #}
{% do sprout.twigDataSet.addRow([
"Client Tier 1",
"Line 1"~ lineBreak ~ "Line 2"
]) %} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
This isn't really a feature request so much as a support request while I try out Data Studio.
This may be more of an issue of not fully grokking some more advanced concepts in Twig templating, but I'm unclear on how I can display related data for a particular element/object.
In my particular use case, I want to generate a report that shows a list of users and the data from a table in their "profile". The table is just a simple Table field in Craft and it can have any number of rows.
My hope is that the resulting report would show the table column as a list of the related table data, either separated by a comma or line break.
Here's a screenshot of example data that I pulled using Twig how I would normally use it in a front-end template. The "tasks" column is a list of key value pairs (task and status).
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions