[TYPO3-english] Extbase/Fluid extension: viewhelper to return associative array (T3 6.2.4)

Jo Hasenau info at cybercraft.de
Mon Feb 23 19:46:18 CET 2015


> 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?

We are using a similar view helper for the THEMES project:

https://github.com/typo3-themes/themes/blob/master/Classes/ViewHelpers/ArrayIndexViewHelper.php

And here is an example of that view helper in themes_gridelements:

https://github.com/typo3-themes/themes_gridelements/blob/master/Resources/Private/Templates/Elements/Carousel.html

HTH

Joey

-- 
Diversity:
Die Kunst zusammen unabhängig zu denken
The art of thinking independently together.
--
Facebook: https://www.facebook.com/johasenau
Twitter: http://twitter.com/bunnyfield
Xing: http://contact.cybercraft.de
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-english mailing list