[TYPO3-mvc] Fluid - accessing an object property by a dynamic index

Alexander Dick alex at dick.at
Tue Sep 14 21:15:52 CEST 2010


Hi Bastian,

Cool, I already thought about a ViewHelper, but I did not know how to 
implement it.
Still, with this PropertyViewHelber I do not quite get how this would 
work in my case.

<f:for each="{data}" as="item">
	{someOtherObject.`item.uid`.title}
</f:for>

cheers
Alex

On 2010-09-14 18:28, Bastian Waidelich wrote:
> Alexander Dick wrote:
>
> Hi Alexander,
>
>> I wonder if it is possible to access a template object by a dynamic
>> index:
>
> This is not possible with the current syntax and I doubt that it will
> come. See http://forge.typo3.org/issues/7618 for more informations.
>
> But there is already a ViewHelper on it's way that will make this
> possible. It will take a while probably until it's in the core, but you
> can already implement it yourself. It looks something like
>
> class Tx_YourExt_ViewHelpers_PropertyViewHelper extends
> Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
>
> /**
> * @param string $propertyName
> * @param mixed $object
> * @return mixed
> */
> public function render($propertyName, $object = NULL) {
> if ($object === NULL) {
> $object = $this->renderChildren();
> }
> return Tx_Extbase_Reflection_ObjectAccess::getPropertyPath($object,
> $propertyName);
> }
> }
>
> and you can use it like
> {object -> f:property(propertyName: foo)}
>
> HTH,
> Bastian
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
>


More information about the TYPO3-project-typo3v4mvc mailing list