FileMaker, PHP and FMWebFrame

Finally it's done! The blog on the new APJ web site (the one you are reading now) is now pulling content from a FileMaker database. It really is made very easy with FMWebFrame. I'm really excited about the possibilities this opens up for FileMaker web publishing...

I must say a huge Thank You to Tim Dietrich for creating such an awesome add-on to the FileMaker API.

Before you start coding the page you will need to complete the FMWebFrame setup according to the instructions here

Once that's done there really isn't much php code required to pull the list of blog summaries from the database. first load fmwebframe.

require_once ( dirname(__FILE__) . '/../FMWebFrame/FMWebFrame.php');

Build the ExecuteSQL request

$query = 'SELECT Title, PostSummary, pagelink 
FROM Posts  
WHERE isOnline = 1  AND Category = \'blog\'  
ORDER BY Page_Date DESC';  

Execute the query.

$blogposts = fmExecuteSQL ( $dbname, $query );

Loop over the results to output the data.

foreach ( $blogposts as $row ) {    

// Convert row into associative array.  
(Makes it easier to use the results.)
$columns = fmGetRow ( $row, 'Title, PostSummary, pagelink' );

echo '<h4>' . $columns['Title'] . '</h4>';

echo html_entity_decode($columns['PostSummary']);

"PostSummary" is generated using Markdown and may include paragraph, link, image and list tags. Using html_entity_decode(); ensures that these tags get interpreted correctly.

Next add a link to the full blog post and close the foreach loop.

echo '<p>';
echo '<a href="/blog/' . $columns['pagelink'] . '">read more</a>';
echo '</p>';

} // close the for each loop

That's it really. Of course in the implementation for this site there are more fields used and a lot more html code to make the page pretty, but fundamentally the code above is all you need. See the result here

The other issue I had to deal with was understanding the url rewrite rules to produce the friendly urls

That's a whole topic in itself and will have to wait for another post...