We have posted before on how to display previous/next thumbnails for image nodes. We also have a module that is basically a Previous/Next API for high volume / high performance sites.

But sometimes you need a simpler solution for regular nodes, just using the node title and a link to it. This article explains how to achieve that for Drupal 6 in one simple function and a few changes to one .tpl.php file.

First, we start off with the code that does the heavy lifting.

In your theme's template.php add the first function from the attached file. By default it provides paging for blog posts only. You can change that to another type of node (or multiple types).

The code is fast, since it uses the nid as an index. So if you use this on large sites, it would not slow them down.

Then in your node.tpl.php, or node-TYPE.tpl.php, add the second snippet in the attached file. This provides calls to the next/previous node with hyperlinked titles.

For the styling, add the CSS from last snippet in the attached file.

The final result will look like this on a garland theme:

Hope you enjoy this ...

AttachmentSize
Plain text icon prev-next-node-paging.txt2.01 KB

Comments

Thu, 2009/12/10 - 06:29

Thanks for sharing this uesful snippet
Too bad this can't be done with view and arguments
Arguments in view needs other comparison operators than equal

keep going

Mon, 2009/12/28 - 10:15

This is an excellent little snippet.

One draw back is that your nodes must be in sequential order, such as node/21, node/22, node/23.
If node/22 is taken up by a different content type, then next button will not appear on node/21.

Is there a work around for this?

Thu, 2010/11/04 - 05:47

Hi, thank you for sharing this.
Could you please give me some advice/solution what to change in your script to sort blog's entries by date-created instead of node-id?
I would really appreciate your help...

Thank you...

Thu, 2010/11/04 - 14:48

Hello again,
I found it out. Anyone interested: i left the solution in this thread http://groups.drupal.org/node/97519#comment-333084

Regards.

Is your Drupal or Backdrop CMS site slow?
Is it suffering from server resources shortages?
Is it experiencing outages?
Contact us for Drupal or Backdrop CMS Performance Optimization and Tuning Consulting