EE 5.2.4
I'm trying to create an array that can be looped through as tagdata in the frontend template.
My method grabs results from an API query, identifies images from the result, assembles them into an array, and parses them into tagdata.
function item_detail ()
{
$id = ee()->TMPL->fetch_param('id');
$result = $this->query_product($id);
$variables = array();
foreach ($result['digital_assets'] as $asset) {
if ($asset['asset_resource_type'] == 'image' ) {
$variables[0]['images'][] = $asset['url'];
}
}
return ee()->TMPL->parse_variables(ee()->TMPL->tagdata, $variables);
}
This gives me an array that looks like this
Array
(
[0] => Array
(
[images] => Array
(
[0] => http://domain.com/image/1.jpg
[1] => http://domain.com/image/2.jpg
[2] => http://domain.com/image/3.jpg
[3] => http://domain.com/image/4.jpg
[4] => http://domain.com/image/5.jpg
)
)
)
I would like to be able to loop through this array in the template like this
{images}
// value
{/images}
There must be a way to do this?
Thanks!