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

Henjo Hoeksma me at henjohoeksma.nl
Thu Nov 3 10:28:11 CET 2011


Hi Roland,

you can use an iterator for this

<f:for each="{produkts}" as="produkt" iteration="produktIterator">
<f:if condition="{produktIterator.isFirst}">
...

See the Fluid Viewhelper for if on the possibilities you have.

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.


On Thu, Nov 3, 2011 at 09:46, Roland <most.wanted at gmx.at> wrote:

> 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
>        (
>            [**0000000007f694db0000000036e567**48] => 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] =>
>                )
>
>            [**0000000007f694c50000000036e567**48] => 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 ---
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list