Hi Hagen,
create a ViewHelper class, that builds up your array like this:
class MyViewHelper extends AbstractViewHelper {
public function render() {
$returnArray = array('a' => 17, 'b' => 42);
$this->templateVariableContainer->add('returnArray',
$returnArray);
$output = $this->renderChildren();
$this->templateVariableContainer->remove('returnArray');
return $output;
}
}
With this, you can do in your FluidTemplate:
<namespace:My>
{returnArray.a} some HTML {returnArray.b}
</namespace:My>
Hope this helps
Anja
On 20.02.2015 07:53, Hagen Gebauer wrote:
Hi,
I'd like to have a viewhelper return an associative array like
class ArrayreturnViewHelper extends
\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
$array['valueOne'] = 'abc';
$array['valueTwo'] = 'def';
return $array;
}
I want to call these values directly, not in a loop. This way did not work:
<namespace:arrayreturn.valueOne /> (TYPO3 will be looking for
ViewHelpers/Arrayreturn/ValueOneViewHelper.php)
Is there a way to do it or do I really have to add a ViewHelper for each
of the values?
Thanks a lot in advance!
Cheers,
Hagen.
_______________________________________________
TYPO3-english mailing list
[email protected]
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english