下面的图片导航来自 http://willwyatt.com/node/1568 ,我在 drupal 4.7.3 上试验成功。
<?php
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$previous=0;
$next=0;
$tmp_prev=-1;
$terms = taxonomy_node_get_terms_by_vocabulary($node->nid, _image_gallery_get_vid());
if ($terms) {
$term = array_pop($terms);
$res = db_query("SELECT n.nid FROM {term_node} t INNER JOIN {node} n ON t.nid=n.nid WHERE n.status=1 AND n.type='image' AND t.tid=%d ORDER BY n.sticky DESC, n.created DESC", $term->tid);
$tot_num = db_num_rows($res);
for($i=0; $i < $tot_num; $i++) {
$nidvalue=db_result($res,$i);
if($previous!=0 && $next==0) {
$next=$nidvalue;
}
if($nidvalue == intval($node->nid)) {
$previous=$tmp_prev;
}
$tmp_prev=$nidvalue;
}
$prev_node = node_load(array('nid' => $previous));
$next_node = node_load(array('nid' => $next));
$prev_th = ($previous == -1) ? '' : l(image_display($prev_node, 'thumbnail', array('width' => '120', 'height' => '120')),'node/'.$prev_node->nid, array(), null, null, FALSE, TRUE);
$next_th = ($next == 0) ? '' : l(image_display($next_node, 'thumbnail', array('width' => '120', 'height' => '120')),'node/'.$next_node->nid, array(), null, null, FALSE, TRUE);
$output = '';
$output .= '';
$output .= '';
$output .= '' . $prev_th . '' . (($previous == -1) ? ' ' : l('Previous','node/'.$prev_node->nid, array(), null, null, FALSE, FALSE)) . '' . $next_th . '' . (($next == -1) ? ' ' : l('Next','node/'.$next_node->nid, array(), null, null, FALSE, FALSE)) . '';
$output .= '' . $tot_num . ' photos in this album.';
$output .= '';
$output .= '';
print $output;
}
}
?>
<?php
$match = FALSE;
$types = array('image' => 1);
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
$type = $node->type;
if (isset($types[$type])) {
$match = TRUE;
}
}
return $match;
?>
.image_browser td {
padding: 5px 0 0 5px;
}