The current version of this module has some nice code for you to copy from the .module file and use in your template.php file, so you can have a nice theme_links-rendered list. There is also an example theme function in a file packaged with the module, that demonstrates how to show the previous/next node titles in the pager.

The second method is more resource-intensive, as it calls two further [expensive] node_load()s that are not required, other than to fetch the title from the nodes either side of the current one. In a smaller site, the cost of the operation may be outweighed by the benefit of the links being titled. Also, there is a marginal case for SEO improvement here (internal linking).

That said, here is a function which performs the second task, as per eaton's code from theme_sample.php - this version, however, is rewritten so that the rendered html is in a similar format to that of the function in the actual module. The module code renders a themed list of links; the demo code currently outputs a div. Anyway, enough of my yakkin', here's some code.

function s4w_custom_pager($nav_array, $node, $pager) {
  if (is_numeric($nav_array['prev'])) {
    $prev = node_load($nav_array['prev']);
  }
  if (is_numeric($nav_array['next'])) {
    $next = node_load($nav_array['next']);
  }
  if ($prev || $next) {
    $links = array();
    $links['custom_pager_prev'] = array(
      'title' => t('« ' . $prev->title),
      'href' => !empty($nav_array['prev']) ? 'node/'. $nav_array['prev'] : NULL,
    );
    $links['custom_pager_index'] = array(
      'title' => ($nav_array['current_index'] + 1) .' of '. count($nav_array['full_list']),
    );
    $links['custom_pager_next'] = array(
      'title' => t($next->title . ' »'),
      'href' => !empty($nav_array['next']) ? 'node/'. $nav_array['next'] : NULL,
    );
  }
  return theme('links', $links, array('class' => "custom-pager custom-pager-$pager->pid custom-pager-$node->type"));
}

NB I don't know how eaton created the ' â~@º' strings in the original theme function (these render as a single angled quote) - they won't work if you cut & paste from the code or enter the entity code either. In my actual function I had to use vim to copy the relevant chunk and reuse the actual lines that way.

Comments

niklp’s picture

Sorry... here's a better (tested) version, that has checks in to see if prev/next are set - if not, it won't try to output a dud pager element. Basically just added the if ($prev) { } check and similar for next.

function s4w_custom_pager($nav_array, $node, $pager) {
  if (is_numeric($nav_array['prev'])) {
    $prev = node_load($nav_array['prev']);
  }
  if (is_numeric($nav_array['next'])) {
    $next = node_load($nav_array['next']);
  }

  if ($prev || $next) {
    $links = array();
    if ($prev) {
      $links['custom_pager_prev'] = array(
        'title' => t('« ' . $prev->title),
        'href' => !empty($nav_array['prev']) ? 'node/'. $nav_array['prev'] : NULL,
      );
    }

    $links['custom_pager_index'] = array(
      'title' => ($nav_array['current_index'] + 1) .' of '. count($nav_array['full_list']),
    );

    if ($next) {
      $links['custom_pager_next'] = array(
        'title' => t($next->title . ' »'),
        'href' => !empty($nav_array['next']) ? 'node/'. $nav_array['next'] : NULL,
      );
    }
  }
  return theme('links', $links, array('class' => "custom-pager custom-pager-$pager->pid custom-pager-$node->type"));
}
niklp’s picture

...aaaand obviously rename the function according to your theme/engine name, don't stupidly leave it as 's4w' which I did...

wayland76’s picture

Ok, so presumably this needs to be put in some documentation somewhere.

ericpugh’s picture

Does anyone know how to get this to work in D6? I can't get this function to work. Also can't seem to get the custom-pager.tpl.php to work. ?? Thank you.

ericpugh’s picture

Nevermind, its working. Must have been an extremely long cache. Thank you very much for the help!

niklp’s picture

This is only tested under D5. If it works under E6, that's great, but you are likely to have to clear your theme cache to make this appear. I still haven't quite worked out what that's about, but still...

joachim’s picture

Hey Nik you want to add your examples here: http://drupal.org/node/387786

(and E6 is an awesome piece of software!)