I'm completely stuck with trying to get Custom Pagers to display node titles instead of prev/next links in D6.

Tried everything, even changing the module by inserting a function that worked in D5 but to no avail.

Also installed the token module, but this does not seem to make any difference. The Custom Pager will not take [title] or [node-title] as an argument.

There must be a way to accomplish this...


varkenshand’s picture

I seem to be the only person in the world having this problem...

pheinrich’s picture

Rolled back... same result. Suppose I'll have to dig into the code now.

pheinrich’s picture

No, I'm having the same issue. Did you ever find a resolution? I'm using the dev snapshot, as recommended by http://drupal.org/node/371358, but I'm about to roll back to 6.x-1.10-beta1 to see if that version works. If it does, it should be easy enough to zero in on the problem.

pheinrich’s picture

I spent some time looking at this and don't really see how it ever "used the page title by default" (as stated by the documentation). I'm no PHP programmer, but that didn't prevent me from hacking a work-around, below. I'm posting it in case it helps you out--but bear in mind it might be whack. (It seems to work for me, but who knows if it's performant, etc.)

The patch should be applied against the dev snapshot.

--- ../custom_pagers.module	2009-09-06 07:45:56.000000000 +0000
+++ custom_pagers.module	2009-09-06 07:48:59.000000000 +0000
@@ -288,9 +288,25 @@
   $pager = $vars['pager'];
   $nav = $vars['nav_array'];
-  $vars['previous'] = !empty($nav['prev']) ? l('‹ ' . t('previous'), 'node/'. $nav['prev']) : '';
+  $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['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
-  $vars['next'] =  !empty($nav['next']) ? l(t('next') . ' ›', 'node/'. $nav['next']) : '';
+  $vars['next'] =  !empty($nav['next']) ? l($next . ' ›', 'node/'. $nav['next']) : '';
   $vars['suggestions'][] = "custom-pager-{$vars['position']}";
   $vars['suggestions'][] = "custom-pager-$node->type";
jonlibrary’s picture

I'm working on a custom pager for a multi-user blog, where posts from different users are linked together by a custom content type. So I've used "newer" and "older" as follows:

$newer = node_load($nav['prev']);
$newer = node_page_title($newer);
$older = node_load($nav['next']);
$older = node_page_title($older);

$vars['previous'] = !empty($nav['prev']) ?l('< ' . $newer, 'node/'. $nav['prev']) : '';
$vars['key'] = t('@count of @count_total', array('@count' => ($nav['current_index'] + 1), '@count_total' => count($nav['full_list'])));
$vars['next'] = !empty($nav['next']) ?l($older . ' >', 'node/'. $nav['next']) : '';

Like the previous commenter, I'm not much of a programmer, so if there's a problem here, please let me know.

jonlibrary’s picture

On another post, joachim says "No need to call node_page_title(). Just say $node->title.
And it's *essential* for security that you run it through check_plain()! That's raw user input you are printing there!"

jonlibrary’s picture

lolandese’s picture