[TYPO3-mvc] ObjectStorage m:n loop in Fluid nur ber for in for mglich?

jacques jvalet at gmail.com
Sat Jan 31 13:04:34 CET 2015


Hi Matthew

Meanwhile I made a new test Ext as written on Marcels webpage:
http://lbrmedia.net/codebase/Eintrag/extbase-bidirektionale-mm-relation/

I have the same Issue with that.

The goal ist that a Feuser (logged-in) can see all available clients and pick his favorites. So every Feuser can have many clients and each client can be picked by many Feusers. The table relations are correct. In the backend I can see and update the relations on every side (clients can pick Feusers from the list and vice versa.

So I must still loop all clients in my opinion. Do you agree?

Please find all the data needed in my Gist:
https://gist.github.com/metaxos/91622c536588d0aa8440

The ZIP of the extension can be found here: http://www.filedropper.com/testmm000201501311251

Regards
Jacques

Quote: Matthew Colton wrote on Sat, 31 January 2015 11:09
----------------------------------------------------
> Hi,
> it would make sense to add the feuser part to the repository query
> (getClients) and not to loop through all clients to check if they fit to
> the client. Then you would have {client.feuser} for instance. It's
> rather likely that is already the case. Have you tried a
> 
> <f:debug>{clients}</f:debug>
> 
> in the template?
> 
> -- 
> Cheers,
> Matthew
> 
> Am 30.01.2015 um 22:05 schrieb jacques:
> > Hallo zusammen
> >
> > Für eine Erweiterung (. Extbase 6.2) habe ich eine m:n Verbindung
> > zwischen Feusers und Clients. Jeder Feuser kann mehrere Klienten haben.
> > Ich habe die Relation mit Extension-Builder angelegt und im Backend
> > funktioniert alles wie erwartet.
> >
> > Ziel ist, dass in der Liste aller Klienten markiert wird ob die Zeile
> > des Klienten mit dem angemeldeten Feuser passt -> dann soll ein Icon
> > erscheinen.
> >
> > Das gelingt mir nur wenn ich ich die for-Klienten-Schleife noch über
> > die Feuser->Klienten eine Schleife baue.
> > Aber wie kann ich die innere for-Schleife vermeiden (siehe unten)?
> >
> > ----------------------------------------------
> > Feusers model:
> > /**
> > * Clients
> > *
> > * @lazy
> > * @var
> > \TYPO3\CMS\Extbase\Persistence\ObjectStorage<Exapoint\Exaibbrplus\Domain\Model\Clients>
> > */
> > protected $clients;
> >
> > /**
> >  * __construct
> >  */
> > public function __construct() {
> >    $this->initStorageObjects();
> > }
> >
> > /**
> > * Initializes all ObjectStorage properties.
> > *
> > * @return void
> > */
> > protected function initStorageObjects() {
> >    $this->clients = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
> > }
> >
> > /**
> > * Returns the clients
> > * @return
> > \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Exapoint\Exaibbrplus\Domain\Model\Clients>
> > $clients
> > */
> > public function getClients() {
> >    return $this->clients;
> > }
> >
> > ----------------------------------------------
> >
> > Liste:
> > <f:for each="{clients}" as="client">
> >    <tr>
> >        <td>
> >            <f:for each="{feusers.clients}" as="singleClient">
> >                <f:if
> > condition="{client.identifier}=={singleClient.identifier}">
> >                    <span class="glyphicon glyphicon-star"
> > aria-hidden="true"></span>
> >                </f:if>
> >            </f:for>
> >        </td>
> >    </tr>
> > </f:for>


More information about the TYPO3-project-typo3v4mvc mailing list