getImageList select all MIGX entries with same ID as current resource

I have a MIGX TV trainer which contains next to name, image, etc. a MultiSelect TV called teamsMultiSelect. The teamsMultiSelect TV is filled with the IDs of all the available team resources (field name is teams). For each trainer I can select one or more teams.

Now I want to display on each team resource all trainers which have the respective team selected in their teams TV. My thought was to filter this in the getImageList call by using the &where property, but afaik this is wrong syntax but I guess it helps to clarify my goal:

  &tpl=`@CODE: <li>[[+name]]</li>`

Is there a way to achieve this using MIGX or do I have to take a different approach on this?

Reading your last questions, I have the feeling it would be better and easier, if you would have some custom-tables instead of the MIGX-TVs.

I think for this case, you would need a custom snippet to search and filter the MIGX - items.

My last question was actually referring to a different project but I try to use a similar method here.

I was planning on switching to MIGXdb for this actually, I was just first testing things the (for me) simpler way. If I would have everything setup in a custom table, would I still need a custom snippet or is there a way with migxLoopCollection then?

Maybe it works if you use find_in_set instead of IN.


when you set up a proper XPDO schema with a connection - table between teams and trainers, the filtering could be done with migxLoopCollection alone.
But you would need a aftersave - hooksnippet, or plugin at onDocFormSave if Resources are involved, which would resolve the entries into this connection-table after saving.

That totally worked! I didn’t know this operator even existed as it’s not listed in the docs.

Is there any significant disadvantage in using this method compared to the one @bruno17 described?

The MIGX method can get slow at some point with a lot of items.

With a many2many connection-table you can work easily in both directions.
Select/view connected teams for a trainer or select/view trainers for a team.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.