Hello,

There are some posts , including the module Custom pager, telling how to add custom pager to node display. However, these methods only use '<

>' for the pager.

Anyone know how to use node titles instead of NEXT and PRE for navigation?

Thanks.
Derek

Comments

red-pea’s picture

I got the problem,too

who could help us?

WorldFallz’s picture

the book module adds this automatically when you add nodes to the hierarchy.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

japanitrat’s picture

the output of a custom pager can be overriden in your theme's template.php. That way you have full access on the nodes and therefore also the option to print the titles instead of 'previous' / 'next' ..

Augusto Ellacuriaga’s picture

Would you mind sharing that? Thanks

International SEO

Slovak’s picture

Interested in solution as well

captix’s picture

still looking for answers

Slovak’s picture

Documented approach with the web site using it: Use Node Title for Custom Pagers

arnemaine’s picture

Can anyone give more detailed instructions on how to use node titles or even better some other node content to replace the previous and next in the Custom Pager?

I am unskilled at how to work with template files, and so the instructions here aren't enough for me.

asb’s picture

+

bmango’s picture

Hi there,

I was also trying to use the node titles for previous and next as it is better for SEO.

I did it by over-riding the custom-pager.tpl.php file.

You can replace the whole file with the code below (which I adapted from the original template). Once you have replaced the code, save the new custom-pager.tpl.php file into your own theme folder.

I'm not a php expert so the code may be a little rough but it works.

<?php
// $Id: custom-pager.tpl.php,v 1.1.2.1 2008/12/24 00:58:21 eaton Exp $

/**
 * @file
 * custom-pager.tpl.php
 *
 * Theme implementation to display a custom pager.
 *
 * Default variables:
 * - $previous: A formatted <A> link to the previous item.
 * - $next: A formatted <A> link to the next item.
 * - $key: Formatted text describing the item's position in the list.
 * - $position: A textual flag indicating how the pager is being displayed.
 *   Possible values include: 'top', 'bottom', and 'block'.
 *
 * Other variables:
 * - $nav_array: An array containing the raw node IDs and position data of the
 *   current item in the list.
 * - $node: The current node object.
 * - $pager: The pager object itself.
 *
 * @see custom_pagers_preprocess_custom_pager()
 */

//adapted code starts ...

$prev = node_load($nav_array['prev']);
if ($prev) {
$ppath = $prev->path;
$ptitle = $prev->title;
$plink = l('< '.$ptitle, $ppath);
}
$nxt = node_load($nav_array['next']);
if ($nxt) {
$npath = $nxt->path;
$ntitle = $nxt->title;
$nlink = l($ntitle.' >', $npath);
}

?>
<div class="custom-pager">
<ul class="custom-pager custom-pager-<?php print $position; ?>">
<li class="previous"><?php print $plink; ?></li>
<li class="key"><?php print $key; ?></li>
<li class="next"><?php print $nlink; ?></li>
</ul>
</div>