Add next link to node

  1. <?php
  2. function next_node_link($type, $object, $teaser = FALSE) {
  3.   $links = array();
  4.  
  5.   if ($type == 'node' && isset($object->nid)) {
  6.     if (!$teaser) {
  7.       if (user_access('access content')) { // do permission checks - this is fairly open
  8.         $nid = db_result(db_query_range("SELECT nid from {node} WHERE status = 1 AND nid > %d ORDER BY nid", $object->nid, 0, 1));
  9.         if($nid) {
  10.           $links['next'] = array(
  11.             'title' => t('Next node'),
  12.             'href' => 'node/'. $nid,
  13.             'attributes' => array('title' => t('The next entered node.'))
  14.           );
  15.         }
  16.       }
  17.     }
  18.   }
  19.   return $links;
  20. }