[TYPO3-mvc] FLUID :: how can you access properties of m:n related objects?

Roland most.wanted at gmx.at
Thu Nov 3 09:46:06 CET 2011


hi everybody,

in the domain model there is an object "Produkt" with an relation 
"zulassungen", which is m:n related to the object "Zulassung".

now i want to output the property "name" of the first related 
"Zulassung" of the "Produkt"s in my FLUID template list view.

QUESTION: how can i access the name of the first related "Zulassung" of 
an "Produkt" in my FLUID template?

i tried this:

--- quote ---

<ul>
<f:for each="{produkts}" as="produkt">
	<li>{produkt.name} - {produkt.zulassungen.0.name}</li>
</f:for>
</ul>

--- /quote ---

...but only the "name" of the "Produkt"s is outputted.

when i debug {produkt} via the debug viewhelper within the for 
viewhelper, something like this is what is outputted for each "Produkt":

--- quote ---

|Object:

Tx_Extbase_Persistence_ObjectStorage Object
(
     [warning:Tx_Extbase_Persistence_ObjectStorage:private] => You 
should never see this warning. If you do, you probably used PHP array 
functions like current() on the Tx_Extbase_Persistence_ObjectStorage. To 
retrieve the first result, you can use the rewind() and current() methods.
     [storage:protected] => Array
         (
             [0000000007f694db0000000036e56748] => Array
                 (
                     [obj] => Tx_Gebroprodukte_Domain_Model_Zulassung Object
                         (
                             [name:protected] => OTC
                             [uid:protected] => 2
                             [_localizedUid:protected] => 2
                             [_languageUid:protected] => 0
                             [pid:protected] => 85
 
[_isClone:Tx_Extbase_DomainObject_AbstractDomainObject:private] =>
 
[_cleanProperties:Tx_Extbase_DomainObject_AbstractDomainObject:private] 
=> Array
                                 (
                                     [name] => OTC
                                     [uid] => 2
                                     [pid] => 85
                                 )

                         )

                     [inf] =>
                 )

             [0000000007f694c50000000036e56748] => Array
                 (
                     [obj] => Tx_Gebroprodukte_Domain_Model_Zulassung Object
                         (
                             [name:protected] => Freihand
                             [uid:protected] => 3
                             [_localizedUid:protected] => 3
                             [_languageUid:protected] => 0
                             [pid:protected] => 85
 
[_isClone:Tx_Extbase_DomainObject_AbstractDomainObject:private] =>
 
[_cleanProperties:Tx_Extbase_DomainObject_AbstractDomainObject:private] 
=> Array
                                 (
                                     [name] => Freihand
                                     [uid] => 3
                                     [pid] => 85
                                 )

                         )

                     [inf] =>
                 )

         )

     [isModified:protected] =>
)

|
--- / quote ---


More information about the TYPO3-project-typo3v4mvc mailing list