You are here

function prev_next_nid in Previous/Next API 7.2

Same name and namespace in other branches
  1. 6 prev_next.module \prev_next_nid()
  2. 7 prev_next.module \prev_next_nid()

Callable API function to get the next/prev nid of a given nid

Parameters

string $nid: The node id of the current node.

string $op: The operation to perform. prev gets the previous node, next gets the next node.

Return value

string $nid The node id of either the previous or next node of the current node.

1 call to prev_next_nid()
prev_next_block_view in ./prev_next.block.inc
Implements hook_block_view().

File

./prev_next.module, line 380
The previous next module indexes the previous and next nodes based upon user-selectable criteria and stores this index in the database for faster retrieval later.

Code

function prev_next_nid($nid, $op = 'next') {
  foreach (module_implements('prev_next_nid') as $module) {
    $function = $module . '_prev_next_nid';
    $ret = $function($nid, $op);
    if ($ret !== FALSE) {

      // If the function returns FALSE, keep trying other methods
      return $ret;
    }
  }
  switch ($op) {
    case 'prev':
      return prev_next_nid_prev($nid);
      break;
    case 'next':
      return prev_next_nid_next($nid);
      break;
    default:
      return 0;
  }
}