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

Posted on less than 1 minute read

× This article was imported from this blog's previous content management system (WordPress), and may have errors in formatting and functionality. If you find these errors are a significant barrier to understanding the article, please let me know.

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:

[caption id="attachment_27172" align="alignnone" width="584"]Execute arbitrary PHP using Drupal Devel module. Execute arbitrary PHP using Drupal Devel module.[/caption]

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:

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!