Skip to main content

Node Title for Custom Pagers

Custom Pagers module adds useful navigation to chosen nodes. The navigation can be displayed at the top and/or bottom of node's content, allows selection of specific node types, and further tweaking can be done with views. By default, however, custom pagers can only print <previous next >. How to display the node titles instead? Add this function to the template.php of the chosen theme:

function phptemplate_preprocess_custom_pager(&$vars) {

$nav = $vars['nav_array'];
  $prev = 'prev';
  if (!empty($nav['prev'])) {
    $nodeObj = node_load($nav['prev']);
    if ($nodeObj) {
      $prev = node_page_title($nodeObj);

  $next = 'next';
  if (!empty($nav['next'])) {
    $nodeObj = node_load($nav['next']);
    if ($nodeObj) {
      $next = node_page_title($nodeObj);

$vars['previous'] = !empty($nav['prev']) ? l('‹ ' . $prev, 'node/'. $nav['prev']) : '';
$vars['next'] =  !empty($nav['next']) ? l($next . ' ›', 'node/'. $nav['next']) : '';


Clear all caches and you should see node titles as navigation above/below the node's content. This approach also lends itself to customization for variety of uses, such as displaying pictures as < previous # of # next >. A quick function and some imagination is all that's needed!

Share this post