1. Add the following to one of your custom modules (tested in Drupal 6):
function exhibit_menu() {
$items['exhibit_nodes'] = array( 'page callback' => 'exhibit_nodes', 'access callback' => TRUE, 'type' => MENU_CALLBACK );
}
function exhibit_nodes() {
define('EXHIBIT_DATE_FORMAT', '%Y-%m-%d %H:%M:%S');
$result = db_query('SELECT n.nid FROM {node} n WHERE n.status = 1 ORDER BY n.nid');
$items = array();
while ($node = db_fetch_object($result)) {
$node = node_load($node->nid);
$items[] = array(
'type' => $node->type,
'id' => 'node/' . $node->nid,
'label' => $node->title,
'author' => 'user/' . $node->uid,
'created' => gmstrftime(EXHIBIT_DATE_FORMAT, $node->created),
'changed' => gmstrftime(EXHIBIT_DATE_FORMAT, $node->changed),
'body' => $node->teaser,
'url' => url('node/' . $node->nid, array('absolute' => TRUE)),
);
}
$types = array('node' => array('label' => t('Node'), 'pluralLabel' => t('Nodes')));
$properties = array(
'author' => array('valueType' => 'item'),
'created' => array('valueType' => 'date'),
'changed' => array('valueType' => 'date'),
'url' => array('valueType' => 'url'),
);
print exhibit_json($items, $types, $properties);
}
function exhibit_json($items, $types = NULL, $properties = NULL) {
$exhibit_json = array( 'items' => $items, 'types' => $types, 'properties' => $properties, ); return drupal_to_js($exhibit_json);
}
2. Create a page with the following code (set the input format to ‘PHP code’):
<?php
drupal_set_html_head('<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript"></script>');
drupal_add_link(array('href' => base_path() .'exhibit_nodes', 'type' => 'application/json', 'rel' => 'exhibit/data'));
return '<div ex:role="viewPanel"><div ex:role="view"></div></div>';
?>
3. Add facets to make it more functional:
<?php
drupal_set_html_head('<script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript"></script>');
drupal_add_link(array('href' => base_path() .'exhibit_nodes', 'type' => 'application/json', 'rel' => 'exhibit/data'));
$output = '
<table width="100%"> <tr valign="top"> <td ex:role="viewPanel"> <div ex:role="view"></div> </td> <td width="25%"> <div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="Search"> </div> <div ex:role="facet" ex:expression=".type" </div> <div ex:role="facet" ex:expression=".author" </div> </td> </tr> </table> ';
return $output;
} ?>
This is a subset of the Drupal Exhibit module [1] (thanks Arto [2]).
Laszlo [3]

