Setting drupal_set_title() with FileMaker data?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
TommyK's picture

Greetings,

Hopefully this audience is a good place for this question.

Does anyone know if it is possible to make a custom content type and/or custom page or node template to override the contents of the <title> and <h1> elements on a page with data out of FileMaker in drupal_set_title() based on a URL parameter?

Basically, I want to create only one page that gets its content, title, and headings from FileMaker, but all the information changes depending on the ID in the URL.

Any thoughts?

I'm not well-versed in the structure of Drupal or in PHP or FileMaker. I know just enough to get in trouble.

Thanks!

Comments

In a word, yes

usonian's picture

In a nutshell, the answer is yes, this is possible... the Drupal mechanics are pretty easy - it sounds like what you're describing is a module which defines a menu item that accepts some FileMaker record ID as an argument, then uses that ID to look up a page title and body. (In fact, this is pretty much how Drupal looks up its own content, with URLs like http://example.com/node/1, http://groups.drupal.org/node/21702, et cetera.)

The core Drupal module would need to implement hook_perm() to define a user permission for viewing filemaker data, and hook_menu() to define the path and callback, something like this in Drupal 6:

<?php
function myfmpmodule_perm() {
  return array(
'view filemaker data');
}

function
myfmpmodule_menu() {
 
$items = array();
 
$items['fmp'] = array(
   
'access arguments' => array('view filemaker data'),
   
'page callback' => 'myfmpmodule_page',
   
'page arguments' => array(arg(1)),
   
'type' => MENU_NORMAL_ITEM
 
);

  return
$items;
}
?>

The callback function might go something like:

<?php
function myfmpmodule_page($filemaker_record_id) { //The menu item will pass the value of arg(1) into this function
 
$record = myfmpmodule_get_record($filemaker_record_id);

 
drupal_set_title($record->title);

  return (
$record->body);

}
?>

The biggest question mark is the myfmpmodule_get_record() function. The above function assumes that it will return a simple PHP object with 'title' and 'body' properties, but there are a couple of different ways to get data into and out of FileMaker Pro:

  • If you have FileMaker Server Advanced and the FileMaker PHP API, you could request the record directly from FileMaker (Similarly, you could use FX.php)

This assumes you have a FileMaker server running, and don't mind exposing it to the internet. It can be a bit tricky to set up, and performance can be an issue if you're sending a ton of web requests to FileMaker.

  • Push FileMaker data up to the Drupal database via ESS

Modifying the Drupal database directly via raw SQL clients, especially the core tables, is frowned upon with good reason, but if your module creates its own table (let's say myfmpmodule_data) for the express purpose of storing FileMaker data then you should be OK. That way you could add a myfmpmodule_data table occurence to your FMP database's graph and write to it directly from FMP, and the myfmpmodule_get_record() function above would then only need to query the myfmpmodule_data Drupal table.

However you get the data out of filemaker, the end result would be a URL structure like http://example.com/fmp/12345 http://example.com/fmp/98765, etc. that would look up the specified record from somewhere and use it to set the page title and body accordingly.

Thanks!

TommyK's picture

Thank you for the great start. We'll have to look into this more. I think it could work out really well.

As far as I understand, we are using FX.php with our FileMaker server. Our site is not a heavy traffic site, so that isn't too much of a worry.

I'll follow up later with our progress in case anyone is interested.

This could also be a good

biscuit.tech's picture

This could also be a good place to start from:
http://drupal.org/node/221854

I originally found

TommyK's picture

I originally found this:

http://drupal.org/node/192876

It tells about using variables from Drupal to fill the title field, but I didn't know how to apply FileMaker to it.

here's another possible

biscuit.tech's picture

here's another possible method, I haven't tried it though and I'm not sure if there's a way to get your Filemaker field into whatever the module is going to use to replace title, but at least it's a programmatic way to replace or drupal_set_title at the node level.

http://drupal.org/node/191895

For the record, Tommy

biscuit.tech's picture

For the record, Tommy figured this out, but I thought I would share:
drupal_set_title($query_row['FMP_Field'][0]);

(Drupal 6.x, FX.php, FMServer 10)

FileMaker

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: