using KFM's functions from within your CMS

I am currently working on a few property websites. One thing common about most property websites is that they include multiple images showing various aspects of a property. When it came to writing that part of the application, I chose to use KFM‘s file management skills, combined with a little AJAX magic to make the work easy for the client.

To see a demo of what I’m on about, click here, log in as “propertydemo” with password “propertydemo”, and click to create a new property, or edit an existing one.

The important thing to note there is the attaching of images – to attach a new image, you click Browse, choose an image from your machine, then click Upload. The page will not be reloaded – your new image will just magically appear. To delete an image, hover your mouse over the icon, then click ‘x’. The idea for this is in part based on how WordPress manages images, but is of course better, as I wrote it 😉

How it works is that there is a hidden iframe acting as the target for the image upload form. When you submit your image, the image is submitted into the iframe, which is attached directly to the upload.php of the CMS’s KFM installation. We supply an “onload” function so that the upload.php then refreshes the parent page’s list of images.

Simple really!

The hard part was in adapting KFM so that I could use its functions from within WebME. I won’t explain all the work that went into it, but just that it’s all done, and a recent copy of KFM has all the necessary code.

To attach KFM to your CMS, you just need to include() KFM’s configuration.php and api/api.php, making sure that the configuration.php has a correct $kfm_base_path:


Once that’s done, you have access to all of KFM’s functions, as well as the extra API functions which are not used by KFM itself, but are useful for CMS’s.

If there are any questions about how to use any parts of this, please ask them below – I still haven’t gotten around to writing documentation for KFM, but hopefully I’ll be able to get it done based on questions from the great unwashed (ie: you!).

Comments are closed.

%d bloggers like this: