Modify Islandora objects on-the-fly using Devel "Execute PHP Code"

 Posted on 
 ·  1 minutes reading time

Alan Stanley taught me this trick at an Islandora Camp a few years ago, and when trying to remember it this morning I messed up one critical piece. So I'll post it here so I have something to refer back to when I need to do this again.

The Drupal Devel module includes a menu item for executing arbitrary PHP code on the server. (This is, of course, something you want to set permissions on very tightly because it can seriously wreck havoc on your day if someone uses it to do bad things.) Navigate to /devel/php on your Islandora website (with the Devel module enabled), and you'll get a nice, big ≶textarea> and an "Execute" button:

Execute arbitrary PHP using Drupal Devel module.

Execute arbitrary PHP using Drupal Devel module.

In this case, I'm generating the TECHMD datastream using the FITS module and displaying the results of the function call on the HTML page using the Devel module's dpm() function:

1
2
3
4
include drupal_get_path('module', 'islandora_fits') . '/includes/derivatives.inc';
$object= islandora_object_load('demo:6');
$results = islandora_fits_create_techmd($object, False, array('source_dsid' => 'OBJ'));
dpm($results);

Works like a charm!