I have a channel items
and a channel colors
, and the items
channel has a Playa field item_colors
that links to the colors
channel. What is the best way to loop through the items
entries and output a construct like this?
{
"color_1" : "item_1",
"color_2" : "item_1",
"color_3" : "item_1",
"color_1" : "item_2",
"color_4" : "item_2",
"color_5" : "item_3",
"color_2" : "item_4",
"color_3" : "item_4",
}
The tricky part is outputting the outer entry title from within the Playa field tag pair. I attempted to do this with a Stash variable:
{exp:channel:entries channel="items" dynamic="no" disable="categories|member_data|pagination"}
{exp:stash:item_title}{title}{/exp:stash:item_title}
{item_colors}
"{title}": "{stash:item_title}",
{/item_colors}
{/exp:channel:entries}
But the result is the Stash variable outputs the same (last) entry title for every instance. Something about parse order, undoubtedly… any help would be greatly appreciated.