Inserire questa funzione nel file template.php del vostro tema
function wiki_prev_next($current_node_id = 0, $op = 'p', $parent_node_id = 0){ if($op == 'p'){ $sql_op = '<'; $order = 'DESC'; }else{ $sql_op = '>'; $order = 'ASC'; } $return_string = ''; $sql = "SELECT g.entity_id FROM {field_data_field_wiki_parent} g WHERE g.entity_id $sql_op $current_node_id AND g.field_wiki_parent_nid = $parent_node_id ORDER BY g.entity_id $order LIMIT 1"; $result = db_query($sql, array(':nid' => $current_node_id))->fetchCol(); $nodes = node_load_multiple($result); if (!empty($nodes)): foreach ($nodes as $node) : if ($op == 'p') { $return_string .= '<a href="'.url("node/" . $node->nid).'">' . $node->title . ''; } else { $return_string .= '<a href="'.url("node/" . $node->nid).'">' . $node->title . ''; } endforeach; endif; return $return_string; }
Inserire il seguente codice nel node--xxx.tpl.php (dove XXX sta per il machine name del vostro content type)
<?php print wiki_prev_next($node->nid,'p', $field_wiki_parent[0]['nid']); print wiki_prev_next($node->nid, 'n', $field_wiki_parent[0]['nid']); ?>