| Joomla

Create Tables & Import CSV Data in Your Joomla Database Using Fabrik

Do you have data supplied to you from a client or outside application that you need to create a table to house and then display back the information in a Joomla! site? Fabrik can make this a very quick and easy process for you using the import feature.

Let’s take a look at how to import and display data from a CSV file.

First, if there are headers in your CSV file this will make the first import easier as Fabrik will use those headings to make elements, or the columns in your table. In this example file, we have 1000 records, and they have headers on the columns:

fabrik csv 01

Next, if you don’t have Fabrik installed, you will need to do that step first. You can go to the website and download the extension or download from the Web in the backend of Joomla.

fabrik csv 01a

 

Once you have Fabrik installed:

  • Navigate to Fabrik>Lists
  • Click NEW in the upper left to create a new List
    fabrik csv 02
  • Then, give the List a name, in this example the name is simply “My Data”
    fabrik csv 03
  • Then go to the Data tab on the left hand side, on this tab you can set the name of the table you will be creating with this list. In our example we put “afab_” as a prefix to make sure this table shows up before the other Joomla tables in dropdowns.

  • Then click Save
    fabrik csv 04
  • On the screen after clicking Save, you will need to simply click Save & Close.
    fabrik csv 05 
  • Then you will see the List you just created in the Fabrik List view.
    fabrik csv 05
  • Click View data
  • Now you will be in the data list view and should see an empty table with No Records, click the CSV dropdown and select Import from CSV so we can add the data in from our sample file.
    fabrik csv 07
  • On the next screen you will need to select your csv file from your computer, and then click Continue. NOTE: If you have different settings in your CSV, like a different separating character, you will need to adjust the other fields on this screen.
    fabrik csv 08

  • The next screen will let you know if Fabrik found headings in the file, and ask whether you want to create elements for each of them. In our example it found all of the headings in the CSV and we have selected Yes to make all of them elements.
    fabrik csv 09

  • Click Continue and then you should get a message saying the element creation and the import of data was successful. Then click View Data again to see the records.
    fabrik csv 10
  • You should see the records now listed in the table.
    fabrik csv 11

Now we have created a table, imported all the data in, but only backend Joomla users can see this currently. Let’s now make this visible for visitors to our site.

First, let’s make a few tweaks on the list and elements before we create a menu item for the frontend.

  • Go to Fabrik>Elements
  • Right now all elements are showing in a list, but this would make for a wide table, so let’s make fewer elements show in the list view. Select the ones you don’t want to show and then click Remove from list.
    fabrik csv 13
  • Then, go back to Fabrik>Lists and open the list again. Select the Access tab on the left, and make Edit, Add, and Delete records only done by Super Users. NOTE: You would use your normal Joomla! ACL rules here, for instance, maybe you have Registered users be able to do these actions.
    fabrik csv 14

  • Then let’s make a menu item to see this list from the front end. Go to the menu you want it on and select new. You’ll then make it a menu item type of Fabrik List.
    fabrik csv 14a
  •  Navigate to the frontend of your site and click on the link you made and you should see your list now on the front end, but you can only view it, not edit it.
    fabrik csv 15

Now, to make 1000 records a little easier to navigate, we can use sorting and filters. Let’s add one of each.

  • Go to Fabrik>Elements
    fabrik csv 16
  • Open the Time Zone element, navigate to the List View Settings on the left hand menu, and then select Yes for Allowing sorting. Click Save & Close
    fabrik csv 17
  • If you now go and refresh the front end and you will see you can sort the data on Time Zone by clicking the label.
    fabrik csv 17a
  • Next open the Shirt Size element and go to the List View Settings on the left. Then click the Filter tab, on that tab change Filter Type to Dropdown. Save & Close
    fabrik csv 18
  • Then refresh your frontend list again and you will see you have a dropdown filter at the top to filter the records by shirt size.
    fabrik csv 18a

There are many more things settings you can add to this list and elements, but this is a quick look at how to add some data to your site from a CSV relatively quickly.

Want to learning more about Joomla and Fabrik? Check out our many 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.