I wanted to output a custom html string with Previous/Next API ->

Here's the function I used in the template file to do it hope this helps someone create a cool node pager

<?php
function pn_node($node, $mode = 'n') {
  if (!function_exists('prev_next_nid')) {
    return NULL;
  }

  switch($mode) {
    case 'p':
      $n_nid = prev_next_nid($node->nid, 'prev');
      $link_text = 'previous';
      break;

    case 'n':
      $n_nid = prev_next_nid($node->nid, 'next');
      $link_text = 'next';
      break;

    default:
      return NULL;
  }

  if ($n_nid) {
    $n_node = node_load($n_nid);

    switch($n_node->type) {

      case 'my_content_type':

        if ($mode == 'p') {
              return '<a href="node/' . $n_nid . '" class="prev"><span>' . $n_node->title .'</span></a>';
             }
            else {
              return '<a href="node/' . $n_nid . '" class="next"><span>' . $n_node->title .'</span></a>';
              }
    }
  }
}
?>

Comments

bhosmer’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

Thanks for sharing. You should add this to the Drupal Snippets