I'm trying to build an array of values from 4 entries so I can lay them out in a comparison chart. I figured the best way to do this would be to add all of the values to a nested array. So I've set this up...
{% set plandata = {
'membership-type' : {
'title' : 'Membership Type',
'url' : '',
'price' : '',
'items' : []
}
}
%}
then I'm iterating through a field and trying to add them to the items portion like so...
{% for amenity in entry.availableAmenities %}
{% set plandata.membership-type.items = plandata.membership-type.items|merge(amenity.title) %}
{% endfor %}
However I am getting a Template Error: Unexpected token "punctuation" of value "." ("end of statement block" expected).
Can anyone give me any insight as to what I'm doing wrong?
There are 4 entries, a main "Membership" page that then has a list of amenities assigned to it. Then 3 entries that are the 3 different membership descriptions, each of these entries has amenities assigned to them. I am attempting to build a comparison chart with the main page in column 1, then checkboxes for matching amenities for the 3 membership columns. I figured iterating through the amenities and add them to arrays to kick them out would be best. Opinion?
– user2040962 Feb 21 '18 at 20:02{% set something %} ... {% endset %}to capture the html and then{{something}}later to display it. You can create complex datastructures they way you are trying to in twig, but it is a total pain in the ass. – Marion Newlevant Feb 21 '18 at 20:27