I have a JSON string with some data I want to render in a template. As Fluid arrays are notated in JSON too, I thought I might just take that JSON string and hand it over to fluid, telling it to treat it just like some other array and use it in the template.
Thus gaining a lot of speed and losing overhead (don't have to split the JSON data up to save it in the DB, can template it easily in fluid).
It wouldn't work, at least not how I tried it.
<f:alias map="{item.jsonData}">
{fieldname}
</f:alias>
It - of course - complained it had received a string, not an array.
Do I have to build a viewhelper and do json_decode
before returning the array to fluid? Or is there a more native way?
Here's the basic controller action:
/**
* action show
*
* @param \NAMESPACE\Myext\Domain\Model\Item $item
* @return void
*/
public function showAction(\NAMESPACE\Myext\Domain\Model\Item $item) {
$this->view->assign('item', $item);
}