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

Stephan Schuler Stephan.Schuler at netlogix.de
Fri Feb 20 18:45:08 CET 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hey there.

"{returnValue.a}" would be the correct call, since the view helper Anja suggested introduces that exact variable name.

You would need to call it like this
> <namespace:test>
>   <h1>Test: {returnValue.a}</h1>
>   {returnValue -> f:debug()}
> </namespace:test>

That's basically what the forViewHelper does for each iteration, it introduces a new variable which is named according to the string given as "as" argument of the forViewHelper. You skipped that "as" argument and used always "returnValue".

Another idea would be to create that "return $array" view helper you posted in your first mail and use this one inside an "alias" view helper

> <f:alias map="{returnValue: '{namespace:test()}'}">
>   <h1>Test: {returnValue.a}</h1>
>   {returnValue -> f:debug()}
> </f:alias>

Regards,


Stephan Schuler
Web-Entwickler | netlogix Media

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Web: media.netlogix.de




netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Web: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



- -----Ursprüngliche Nachricht-----
Von: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-bounces at lists.typo3.org] Im Auftrag von Hagen Gebauer
Gesendet: Freitag, 20. Februar 2015 09:41
An: typo3-english at lists.typo3.org
Betreff: [TYPO3-english] Re: Extbase/Fluid extension: viewhelper to return associative array (T3 6.2.4)

Hi Anja,

thanks a lot for your reply. But somehow it doesn't work although there isn't a parsing error at least :) calling {returnArray.a} returns an empty string {namespace:returnArray.a} or {namespace:test.returnArray.a} instead are not being parsed but displayed as is.
(the class is called TestViewHelper that's why I tried to call namespace:test...)

Here is the full class:

class TestViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper {
/**
*
* @return array
*/
public function render() {
$returnArray = array('a' => 17, 'b' => 42);
$this->templateVariableContainer->add('returnArray', $returnArray);
$output = $this->renderChildren();
$this->templateVariableContainer->remove('returnArray');
return $output;
}
}

Cheers,
Hagen.
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english

-----BEGIN PGP SIGNATURE-----
Version: PGP Universal 3.3.2 (Build 15704)
Charset: utf-8

wpUDBQFU53Kmpp0IwsibV8MBCFU+BACbjLLDBi8U9f4b2/uKA1JJER3YHDIKQEyH
jkHNDOAI/W2b1j2uDZR91yq0SwA7sfCcbLVeCvRCB6Z4hlxmLRZE203L0CalvGeW
FCRduZRw6rL9RXRWvUAt2LW1STU1+nZMVTJ8vx+5gGgMdcfRITKT1NwHbXJBND3P
hcAXN5MWgg==
=K6Bv
-----END PGP SIGNATURE-----


More information about the TYPO3-english mailing list