Building a Calender Application in Joomla! using Fabrik

0
165
3 min read

(For more resources on Joomla!, see here.)

Getting ready

You need a working installation of Joomla! 1.5.x. For exercise purpose, you can install that on your local computer. The web server should have PHP5 installed. Then you need to install Fabrik component. This component is available for free from http://fabrikar.com/component/docman/cat_view/6-fabrik-20. Download the latest version of the component and install it from Extensions | Install/Uninstall screen in Joomla! administration panel.

Also plan for the application you want to develop. For example, we are developing an event calender. This event calender will contain the following information:

  • Event Category
  • Event Name
  • Venue
  • Start Date & Time
  • End Date & Time
  • Event Description
  • Attached Document
  • Created by

This is a very simple list of information we need. Based on the we will create two database tables: categories and events. The table structure is shown in the following diagram.

Building a Calender Application in Joomla! using Fabrik

The above table diagrams show that categories table is linked to events table by foreign key category_id. Similarly, we have added user_id field in events table, so that we can link it to jos_users table. Whenever a user creates an event, his or her user ID will be added to this field.

For creating the tables in Joomla! database, connect to that database using phpMyadmin or some other interface, and run the following SQL command:

CREATE TABLE `categories` (
`id` INTEGER AUTO_INCREMENT DEFAULT NULL ,
`name` VARCHAR(200) DEFAULT NULL ,
PRIMARY KEY (`id`)
) COMMENT 'contains categories of events';

CREATE TABLE `events` (
`id` INTEGER AUTO_INCREMENT DEFAULT NULL ,
`category_id` INTEGER DEFAULT NULL ,
`event_name` MEDIUMTEXT DEFAULT NULL ,
`venue` VARCHAR(100) DEFAULT NULL ,
`start` DATETIME DEFAULT NULL ,
`end` DATETIME DEFAULT NULL ,
`description` MEDIUMTEXT DEFAULT NULL ,
`attachment` VARCHAR(250) DEFAULT NULL ,
`user_id` INTEGER DEFAULT NULL ,
PRIMARY KEY (`id`)
) COMMENT 'list of events';

ALTER TABLE `events` ADD FOREIGN KEY (category_id) REFERENCES
`categories` (`id`);

Successful execution of the above code block will create two tables and add a foreign key to events table linking it to categories table.

With creation of these two table we are set to create our event calender application.

How to do it…

Follow the steps below:

  1. From Joomla! Administration panel, click Components | Fabrik |  Connections. That shows existing database connections. By default, connection to Joomla! database is created. You can create  new database connection by clicking New button and filling in the form.
    Building a Calender Application in Joomla! using Fabrik
  2. Click on Tables link in this screen. That shows existing tables created in Fabrik.
    Building a Calender Application in Joomla! using Fabrik
  3. In Table screen, click on New button to add a new table. That shows Table: [New] screen.
    Building a Calender Application in Joomla! using Fabrik

    In Label field type Categories, and in Introduction field, type Event Categories. Then select Yes in Published radio box to the right side. Accept default values for other fields. Then click Access tab. That shows Access Rights.

    Building a Calender Application in Joomla! using Fabrik

    Accept the default values in Access tab. Now click Data tab. From here you have to configure which data table you want to use.

    Building a Calender Application in Joomla! using Fabrik

    From Connection drop down list, select site database. Then click on Link to Table drop down list and select categories table. In Order By drop down list, select name. There are some other options in this tab, but those cannot be configured until you save the table. Now click Save button to save the table.

LEAVE A REPLY

Please enter your comment!
Please enter your name here