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:
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.
Once you have Fabrik installed:
- Navigate to Fabrik>Lists
- Click NEW in the upper left to create a new List
- Then, give the List a name, in this example the name is simply “My Data”
- 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
- On the screen after clicking Save, you will need to simply click Save & Close.
- Then you will see the List you just created in the Fabrik List view.
- 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.
- 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.
- 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.
- 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.
- You should see the records now listed in the table.
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.
- 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.
- 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.
- 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.
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
- 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
- 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.
- 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
- 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.
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.