[TYPO3-mvc] How to get first object of an 1:n relation
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Apr 14 15:22:42 CEST 2011
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
More information about the TYPO3-project-typo3v4mvc
mailing list