Skip to content

Instantly share code, notes, and snippets.

@anarchivist
Created December 24, 2009 17:27
Show Gist options
  • Select an option

  • Save anarchivist/263276 to your computer and use it in GitHub Desktop.

Select an option

Save anarchivist/263276 to your computer and use it in GitHub Desktop.
Use Shrew with Computed Field module in Drupal to store/extract MARC data
<?php
/* Sample Computed Field/Shrew usage for Drupal. The Shrew module [1] uses the
Shrew [2] PHP library to interact with Innovative Interfaces online library
catalog systems.
[1] http://www.github.com/anarchivist/drupal-shrew
[2] http://www.github.com/anarchivist/shrew
*/
if (!$node->nid) {
node_save($node);
}
$delta = 0;
$node_field = array();
if ($bnum = $node->field_iii_single[0]['value']) {
$record = shrew_record_get($bnum);
if ($fields = shrew_field_get($record[$bnum]->bibliographicRecord, '520')) {
foreach ($fields as $field) {
$node_field[$delta]['value'] = $field;
$delta++;
}
}
else $node_field[0]['value'] = NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment