[TYPO3-mvc] How to get first object of an 1:n relation -followUp !
Frank Mey - NEW.EGO
mey_mailings at newego.de
Thu Apr 14 17:54:20 CEST 2011
Hi list,
I'm having a related problem with my heft/article/Rubrik model :).
In the showAction of my HeftController I can see all the articles related to
a single heft
And use them in fluid with {heft.heftZuArtikel.<artikel-property>}.
Is there a way to Order or group the related articles as they are loaded in
the ObjectStorage when I call
The showAction in the HeftController ? I'd like them to be grouped by
categories, my best guess in Fluid was
The groupedFor ViewHelper, like this:
<f:groupedFor each="{heft.heftZuArtikel}" as="artikel"
groupBy="heftZuArtikel.artikelZuBereich" groupKey="rubrik">
But the property "heftZuArtikel.artikelZuBereich" is not accessible.
How could this problem be solved on the extbase side ? If the
article-objects get attached to the objectStorage, is the ArtikelRepository
called and
Can I modify the method by which they are attached ?
Thx for clearing up things in advance, you see I still struggle with that
coding model ;)
Regards,
Frank
> -----Original Message-----
> From: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-
> project-typo3v4mvc-bounces at lists.typo3.org] On Behalf Of Franz Koch
> Sent: Thursday, April 14, 2011 3:23 PM
> To: typo3-project-typo3v4mvc at lists.typo3.org
> Subject: Re: [TYPO3-mvc] How to get first object of an 1:n relation
>
> Hey,
>
> > i've got an 1:n relation called anhaenge.
> > How i get the first object of anhaenge in a fluid view?
> >
> > Is there a way like
{currentObject.anhaenge.first.propertyIlikeToDisplay} ?
>
> not yet. AFAIK there is a review from Felix pending that's implementing a
> "getFirst" method in objectStorages which should actually allow what you
> currently try.
>
> But until this is implemented I'd suggest to do one of the following:
>
> a) simply loop over the "anhaenge"
> b) add a method "getFirstAttachment" to your "currentObject"s domain
> model that's doing the work for you
> c) write a little viewHelper that's able to do what you need
>
> c) would be my favorite because it's most flexible and can be reused for
> other relations.
>
> --
> kind regards,
> Franz Koch
> _______________________________________________
> 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