[TYPO3-mvc] Fluid: Accessing an array item

Xavier Perseguers typo3 at perseguers.ch
Tue Jul 7 22:40:08 CEST 2009


Hi,

> I have an object containing an array as property. How do I output one of 
> its element based on its index?
> 
> In ext:
> $this->view->assign('myObject', $someObject);
> 
> In template:
> 
> {myObject.someProperty}
> 
> someProperty is an array and I want to output one of its element.
> 
> I tried
> 
> {myObject.someProperty.1}
> {myObject.someProperty[1]}
> {myObject.someProperty{1}}
> 
> but nothing works.
> 
> Should I create a custom ViewHelper for this task?

Found that having keys actually works:

$someProperty = array('key1' => 'value1', 'key2' => 'value2');

{myObject.someProperty.key1}

Topic closed :-)

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en

One contribution a day keeps the fork away


More information about the TYPO3-project-typo3v4mvc mailing list