Drupal Association members fund grants that make connections all over the world.
An API for browsing next/previous nodes without overloading your database server.
This module allows you to know the previous or next nodes for any given node. This is very useful for providing navigational links to the user without the expensive queries required to dynamically deduce such information on the fly.
The use case is two fold:
For example, on a site with a gallery of images, you want to show a next/previous link with a thumbnail under each image. Your site's visitor click on the link to show new content or browse it.
Although the previous and next nodes can be deduced with some SQL work, the queries to do so are very heavy on the database, and can bring a site to its knees. This module solves this problem by storing the previous/next node in a table so lookups are fast. Once the module is installed, it will build this index backwards via cron until all nodes have been indexed. See the "More Info" section below for a detailed post on the positive scalability impacts of implementing this module.
The module can be restricted to certain content types to be included in the previous/next indexing. For example, you want the site's visitors to browse through video and image nodes only, but not blogs and regular pages.
The number of nodes to index is defined in the settings too. The default is 200, but you may want to lower that for a site on shared hosts. Once the indexing is complete for all the site's nodes, cron will do do anything. You can always reindex the site using the "Re-Index" button on the settings page.
The module provides only one API call. If you do not call that function, this module will do nothing.
$n_nid = prev_next_nid($nid, $op);
Examples for using it are:
// Get the previous node id $prev_nid = prev_next_nid($nid, 'prev'); // Get the previous node id $next_nid = prev_next_nid($nid, 'next');
To implement the functionality for this module, please see the example in the README.txt file provided with this module.
At present, the module does not provide for indexing content by criteria other than the node type.
The 7.x-2.x version of this module allows indexing of nodes by taxonomy terms as well.
Other use cases may call for additional criteria, for example, a term id, so content is browsed by taxonomy terms. This will require database schema changes and reindexing of the site again.
For more info on the performance impact of this module on large sites, please read Previous/Next API: a high performance API module for previous/next node.
Comparison of Other Solutions
Depending on your site and needs, you may want to compare other methods of generating previous and next links.
The author can also be contacted for paid customizations of this module as well as Drupal consulting, installation, development, and customizations.
- Maintenance status: Actively maintained
- Development status: Under active development
- Module categories: Content Display, Developer, Performance and Scalability, Site Navigation, Theme Enhancements, Utility
- Reported installs: 5,939 sites currently report using this module. View usage statistics.
- Downloads: 22,081
- Automated tests: Enabled
- Last modified: August 31, 2015
- Stable releases are covered by the security advisory policy.
Look for the shield icon below.