Posted by TommyK on April 27, 2009 at 5:44pm
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
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:
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.
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!
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
This could also be a good place to start from:
http://drupal.org/node/221854
I originally found
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
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
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)