function theme_hover_preview in Hover Preview for ImageCache 6
Convenience function to display an applicable field from a node using hover_preview
Usage: theme('hover_preview', $node, 'field_photo', 'small_preset', 'large_preset', 'link to node (TRUE)');
File
- ./
hover_preview.module, line 156 - Hover Preview for Imagecache.
Code
function theme_hover_preview($node, $field_name, $preset_a, $preset_b, $linked = NULL) {
$field = content_fields($field_name, $node->type);
if ($field) {
// If necessary, pass the node through node_view first to sanitise it
if (empty($node->content)) {
$node->build_mode = NODE_BUILD_NORMAL;
node_view($node);
}
// Poke CCK's display settings to use the formatter we want
if (isset($linked)) {
$format = $preset_a . '_hover_preview_' . $preset_b . '_linked';
}
else {
$format = $preset_a . '_hover_preview_' . $preset_b;
}
$field['display_settings']['full']['format'] = $format;
// Invoke CCK to assemble the data structure for us and then render it
$data = content_field('view', $node, $field, $node->{$field_name}, FALSE, FALSE);
$output = drupal_render($data);
return $output;
}
}