• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Inverse DatabaseJoin Element

marcelf

Member
Hi all,

I have the following question:

I created 2 lists: Artists and Bands. In the Artists, I created Band element using databasejoin plugin (multiselect dropdown).

In the Bands list I want to create Artists element. Now I have a problem: If I do this, fabrik will create 2 different NN tables for the same relation. And this obligates the user makes the same relation twice. If the user associates a band in the artists form, it doesn't appear in the band details page and vice versa.

What I want: I want to use the same NN table for both, so I'm thinking about to develop the Inverse DatabaseJoin element. In the administrator>new element>inverse databasejoin plugin, you set the databasejoin element already created in the other group and If the user does a relation in any of two forms, it appears on both. OR... maybe already has another way to do this?

Thanks,
Marcel

ps: In OWL (from the semantic web) it is called inverseOf property
https://www.w3.org/TR/owl-ref/#inverseOf-def
inverse-n.jpg
 
Personally I would do this with List joins rather than a join element.

Create a bands_artists List (which will be a many-to-many junction table) from the standard 'default' list type...

id (internalid element, ie. created by default when you create the list)
date_time (you can delete or unpublish this if you want)
band_id (create a 'field' element, set to type INTEGER)
artist_id (create a 'field' element, set to type INTEGER)

Then in the Bands list, create a join from band.id to bands_artists.band_id, and in the Artists list as artists.id to bands_artists.artist_id. In both cases, set the join to Repeat.

You'll then have a new group on each form, for the repeat. In the Bands copy, you can hide the 'band_id' element, and change the artist_id element type to be a 'databasejoin' (as a single select dropdown) to artists (value 'id', label 'name'), and in the Artists copy hide the artist_id, and set band_id to be a join to bands.

That should then be naturally be an insverseOf. If you add an artist to a band, if you then view that artists form, the band will be listed.

You can set the 'layout' of the repeat groups to be 'table', which would probably be a better visual look.

It does mean that to add an artist to a band (or vice versa), you have to "Add" a new group, and then select the artist from the join dropdown, rather than just selecting them all from a single multiselect.

But on the other hand, it means you can do "other stuff" in the junction table, for example using an autofill plugin, or maybe CDD's, to fill other fields in the junction table (like 'instrument'), taken from the artists (or maybe an artists_instrument) table. Etc.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top