| Joomla

Showing Related Data in Fabrik

Have you ever wanted to show data on a different table that is related to the data on another table in a Joomla site using Fabrik? For instance, let’s say you have a list of members in a race club and a list of races they have completed. This is a very common one-to-many relationship, and it’s easy to display in Fabrik.

Let’s jump in and show the relationship between our racers to races!

So, our objective is to show how many races our members have completed and to link to their race details. So this will be added on to our current member list:

Showing Related Data in Fabrik - fabrik related data

First, let’s take a look at how we have things setup in Fabrik with our two lists. We have one Fabrik List that is the members table that shows information about the member:

Showing Related Data in Fabrik- fabrik related data

And, then we have another Fabrik List that shows information about races completed, with one column that is tied to the Members table, the member name. This is the race info list:

Showing Related Data in Fabrik - data member table

That element that we used for the Member name on the Race information is a “databasejoin” type element.

Showing Related Data in Fabrik - fabrik elements

If we take a look at the settings on that element we can see that we are connecting to the member table and only storing the member id on this race table. Basically, we are creating a one-to-many relationship between the two tables, meaning one member can have many races on the other table.

Showing Related Data in Fabrik - fabrik details

When we look at the form to add a race, we will see that the form is a dropdown to select a member name.

Showing Related Data in Fabrik - related data

Now we could just put a filter on the top of the Race Info list and let people select a member in a dropdown to filter the records to only show the races for that particular member. But, we want to make it easier for them, and we want to see race counts by members on our member list page.

So, we will go

  1. Navigate to Fabrik>Lists
  2. Edit the member List
  3. Go to the Data tab on the left
  4. Select the Related Data tab up top (notice that Fabrik has auto detected the relationship for us because of the databasejoin element)
  5. Select to Yes under Show related data link
  6. Select the Yes radio button un Link to list
  7. Type the Heading for the column in list view (if you leave this blank it will use the list name)

Showing Related Data in Fabrik - related data heading

Then if we return to the front end and refresh our member list, we’ll see the new column for races with the count for each member and a link to view the race details for that member.

Showing Related Data in Fabrik - front end views

If we click the View link, we will be sent to the Race List view pre-filtered to our member:

Showing Related Data in Fabrik - filtering

One more thing we might want to do is add this related data and link on the Details view on each member. If we open up the details on a member currently we do see all their information, but not the number of races or the link:

Showing Related Data in Fabrik - menu item

We can fix this quickly!

  1. Go to Fabrik>Forms
  2. Edit the form for Members
  3. Select the Options tab
  4. Set Show related data links to “Yes”

Showing Related Data in Fabrik - optionsNow if we go back and refresh the member view you will see the Races count and view link up top:

11 fabrik related data

And, tada! We now have a member details page that even shows related data on it.

Our example just used the default look and feel that Fabrik and our template CSS generated, but you can always change the look with custom CSS or even custom templates for lists or details.

Interested in learning more about Joomla and Fabrik? Check out our variety of courses about Joomla and Joomla-related topics.


About the author

Robbie started her career in corporate training until starting her own custom training and media company almost seventeen years ago. In 2010, she began doing classroom training for OSTraining while running Media A-Team. She is often presenting about various tech topics such as Joomla, Fabrik, Web Development, Social Media, and Augmented Reality. She loves seeing that "ah-ha" moment in peoples eyes in her sessions and workshops. She lives in Houston, Texas, but enjoys all the travel for client work and speaking gigs.