Integrating FileMaker and Joomla!

Warning: copy(): Filename cannot be empty in C:\inetpub\\wp-content\plugins\mytube\mytube.php on line 220

The end result of our integration of FileMaker and Joomla!

In this small tutorial, we will look at how FileMaker contents can be shown in a Joomla driven website. Joomla is a very powerful content management system based on PHP and MySQL. Using the FileMaker PHP API, it's quite easy to embed FileMaker data in Joomla.

Note: we are assuming that you have basic knowlegde of Joomla. If you want to learn more about Joomla, please refer to the Joomla website. We are using Joomla 1.0.13 in this tutorial.

1. The Basics

To show our contact list in Joomla!, we will create a component that uses the FileMaker PHP API to show the data. For this tutorial, our objective is to simply show a list of our contacts which are saved in a FileMaker database.

2. Preparing the FileMaker database

In order to be able to access our database via PHP, we need to create a new privilege set that has the extended privilege "Access via PHP Web Publishing" enabled.

Creating the PHP Web Access privilege set

Now, we create a user called "php" with "php" as the password that has this privilege set enabled. We will use this user to connect to the database.

Creating the PHP user

3. Installing the fmcontacts component in Joomla!

The component is packaged as a zip file, which makes it very easy to install it into Joomla. The component can be installed using the administration site of Joomla, under Installers > Components.

Installing the fmcontacts component.

If the component is installed successfully, you should get the following message:

The installation of the fmcontacts component was successful.

4. Creating a menu item for our component

To be able to use the component, we also need to create a menu item that links to our component. We can also do this in the administration part of the web site. To do this, select the proper menu from the menu option (we chose to add the item to the main menu). Then you can click the new button in the toolbar to create a new menu item. As the menu type, select "component" from the list. You will be presented with the following screen:

Adding a new menu item for our component.

When you click on the apply button in the menu bar, you will see that Joomla shows the options for our component.

Setting the parameters for our menu item

You can fill in the parameters as follows:

  • FileMaker Server: the server hosting the database
  • FileMaker Database Name: the name of the database
  • FileMaker Server User: the name of the user to connect to FileMaker server
  • FileMaker Server Password: the password of the user

Don't forget to click the "Save" button once you've filled in the parameters to make sure they are saved.

5. How the module is constructed

The fmcontacts module contains different files (relative to the Joomla installation directory):

  • components/com_fmcontacts/fmcontacts.php
  • components/com_fmcontacts/fmcontacts.html.php
  • administrator/components/com_fmcontacts/admin.fmcontacts.php
  • administrator/components/com_fmcontacts/fmcontacts.xml

5.1 components/com_fmcontacts/fmcontacts.php

This is the main file of our component.

  1. <?php
  3. // No direct access
  4. defined('_VALID_MOS') or die('Restricted access');
  6. // Include the FileMaker API
  7. require_once('FileMaker.php');
  9. // Load the front html file
  10. require_once($mainframe->getPath('front_html'));
  12. // Check which task needs to be executed
  13. switch ($task) {
  15. // Default task
  16. default:
  17. showList($option);
  18. break;
  20. }
  22. // Function to get a filemaker connection
  23. function getFileMakerConnection() {
  25. // Use the mainframe global variable
  26. global $mainframe;
  28. // Get the menu and it's parameters
  29. $menu = $mainframe->get('menu');
  30. $params = new mosParameters($menu->params);
  32. // Open a connection to FileMaker using the menu parameters
  33. $fm = new FileMaker();
  34. $fm->setProperty('hostspec', $params->get('fmserver'));
  35. $fm->setProperty('database', $params->get('fmdbname'));
  36. $fm->setProperty('username', $params->get('fmdbuser'));
  37. $fm->setProperty('password', $params->get('fmdbpass'));
  39. // Return the connection objec
  40. return $fm;
  42. }
  44. // Show the list of contacts
  45. function showList($option) {
  47. // Get a FileMaker connection
  48. $fm = & getFileMakerConnection();
  50. // Get the records from the layout called 'items'
  51. $command = & $fm->newFindAllCommand('Contacts');
  52. $result = $command->execute();
  54. // Check for errors
  55. if (FileMaker::isError($result)) {
  56. echo($result->getMessage());
  57. return false;
  58. }
  60. // Show the view
  61. HTML_fmcontacts::showContactList($result, $option);
  63. }
  65. ?>

If we glance over the source code, we see the following things:

  • line 4: this makes sure the component is only loaded from within Joomla.
  • line 7: this includes the FileMaker PHP API
  • line 10: this includes the fmcontacts.html.php page
  • line 13-20: this code is not really needed, but enables us to make our component do more than one single task
  • line 23-42: this function is a shortcut to get a connection to the FileMaker Server. It loads the configuration parameters from the menu item
  • line 45-63: this function connects to FileMaker, gets the list of contacts from the Contacts layout and loads the fmcontacts.html.php file. If something goes wrong, an error message is displayed.

5.2 components/com_fmcontacts/fmcontacts.html.php

This is the PHP file responsible for showing the HTML needed to display our list:

  1. <?php
  3. // No direct access
  4. defined('_VALID_MOS') or die('Restricted access');
  6. // Class HTML_fmpro_joomla
  7. class HTML_fmcontacts {
  9. // Function to show the list of contacts
  10. function showContactList($result, $option) {
  12. // Output the title
  13. echo('<div class="componentheading">Contact List</div>');
  15. // Start an unordered list
  16. echo('<ul>');
  18. // Loop over the records
  19. foreach ($result->getRecords() as $contact) {
  21. // Show the contact name and firstname as a list item
  22. echo('<li>');
  23. $contact->getField('firstname')
  24. . ' ' . $contact->getField('lastname'));
  25. echo('</li>');
  27. }
  29. // End of the unordered list
  30. echo('</ul>');
  32. }
  34. }
  36. ?>

As you can see, this file loops through the found records and shows them as an unordered list.

5.3. administrator/components/com_fmcontacts/admin.fmcontacts.php

This file contains the administrative side of our component. You can access this in the Joomla administrator under Components > FileMaker Contacts. Currently, it only shows a title and a link.

5.4. administrator/components/com_fmcontacts/fmcontacts.xml

This file contains metadata information which Joomla needs to be able to use the component.

6. The source code and files for this tutorial

5 Responses to “Integrating FileMaker and Joomla!”

  1. tlearyus Says:

    i installed this into Joomla! 1.0.13 Stable [ Sunglow ] 21 July 2007 16:00 UTC and it didn’t work even though it said the component installed successfully

    When i click on it in components menu nothing happens !!

    ANy help would be appreciated.

  2. Crispin Says:

    I’d love to see more on this. The article is from 2007. Have SHP done any more on it since?

  3. Pieter Claerhout Says:

    We found that with the types of websites we create for customers, SilverStripe ( seems to be a much better choice than Joomla. Specifically the handling of multi-lingual content in SilverStripe is much stronger than what Joomla has.

  4. Brian Loomis Says:

    It’s exciting to see how these things keep coming together. There was a time when I was not as impressed with FileMaker and the way that it worked, like it was getting behind. This year though the speakers are great and the conference looks to be good. The FM community is picking up on the finer aspects of development such as unit testing etc.

    I have been working on an interface to 37signals Basecamp API from FileMaker that I will probably be releasing at FMDevCON this year.

    I’m glad to see you guys are pushing the envelope too.


  5. PHP Development for FileMaker Developers - MightyData Says:

    [...] and PHP include Joomla, a content management system (CMS), detailed by the folks from myFMButler on integrating FileMaker and Joomla. Another popular PHP framework is CodeIgniter. With minor modifications it is possible to integrate [...]

Leave a Reply

You must be logged in to post a comment.