Hello,
I am working at creating a gallery of sorts on a clients website. To do so I simply created a content type and am using next/previous buttons to go from one node to the next. I am attaching the code (which I copied from elsewhere on this forum) I am using.
This first code was inserted in my template.php
<?php
function node_sibling($dir = 'next', $node, $next_node_text=NULL, $prepend_text=NULL, $append_text=NULL, $tid = FALSE){
if($tid){
$query = 'SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON n.nid=tn.nid WHERE '
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' :nid AND n.type = :type AND n.status=1 '
. 'AND tn.tid = :tid ORDER BY n.nid ' . ($dir == 'previous' ? 'DESC' : 'ASC');
//use fetchObject to fetch a single row
$row = db_query($query, array(':nid' => $node->nid, ':type' => $node->type, ':tid' => $tid))->fetchObject();
}else{
$query = 'SELECT n.nid, n.title FROM {node} n WHERE '
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' :nid AND n.type = :type AND n.status=1 '
. 'ORDER BY n.nid ' . ($dir == 'previous' ? 'DESC' : 'ASC');
//use fetchObject to fetch a single row
$row = db_query($query, array(':nid' => $node->nid, ':type' => $node->type))->fetchObject();
}
if($row) {
$text = $next_node_text ? $next_node_text : $row->title;