![]() |
Services | Software | Partners | Articles | Contact |
Displaying previous/next thumbnails for image nodesA recent request for a site that uses the image module was to have easier navigation for their collection. The requirements was to have the thumbnail of the previous and next image below the image that is being displayed as a visual cue for the user so they click on the ones that interest them. Of course, with a bit of magic, this is perfectly possible. Two pieces of code are needed. The first go into the template.php of the theme you are using. In this file, add the following function: function pn_node($node, $mode) {Then you copy the node.tpl.php to a file called node-image.tpl.php and add the following snippet to it where you want the thumbnails to appear: <div class="previous-thumbnail"><?php print pn_node($node, 'p') ?></div> You can now use CSS to theme how they should be aligned, and otherwise look. |




fixing the links
The links weren't working correctly. It needs three more lines, e.g. like this:
$n_nid = $node->nid;
switch($mode) {
case 'p':
$n_nid--;
$op = '<';
$order = 'DESC';
break;
case 'n':
$n_nid++;
$op = '>';
$order = 'ASC';
break;
default:
return NULL;
}