This is what I want to do, but it's the closest thing I could find but it doesn't seem to be for Drupal 6, just 4 and 5.

http://drupal.org/node/37767

I'll keep looking until I hear back from someone, any ideas or solutions out there?

Comments

christopherareed’s picture

Found this code on a different website...

 function pn_node($node, $mode) {
  $output = NULL;

  switch($mode) {
    case 'p':
      $op = '<';
      $order = 'DESC';
      break;
    case 'n':
      $op = '>';
      $order = 'ASC';
      break;
    default:
      return NULL;
  }

  $sql = "SELECT nid FROM {node} n
    WHERE nid $op %d
    AND type = 'image'
    AND status = 1
    AND promote = 1
    ORDER BY nid $order
    LIMIT 1";
  $o_nid = db_result(db_query($sql, $node->nid));
  if ($o_nid) {
    $o_node = node_load($o_nid);
    $output = l(image_display($o_node, 'thumbnail'), 
       "node/$n_nid", array(), NULL, NULL, FALSE, TRUE);
  }

  return $output;
}
<div class="previous-thumbnail"><?php print pn_node($node, 'p') ?></div>
<div class="next-thumbnail"><?php print pn_node($node, 'n') ?></div>

It's from 2007 though, and doesn't specify what version of Drupal it was from. I'm assuming a node_load() on everything would be to intensive anyways?

manop’s picture

In my site, I use Custom Pagers - http://drupal.org/project/custom_pagers

I don't know if it's what you're looking for.

christopherareed’s picture

Okay so, I think I understand, but can you clarify a question for me? Say I use custom pagers. What if what I want is to only display the node above and below of a content type say, image. But I want it to display the images above/below the current one shown. So if someone's looking at node/875 or whatever, then it would give a previous/next options to nodes 874 and 876. Know what I mean? I don't want to display all the nodes of a content type and just have dozens of pages in a pager? Does that make sense?

manop’s picture

In my Custom Pager, it shows only "previous" and "next" on the page related to the current node.

I've never tried displaying thumbnails, but I guess it's possible.

dnewkerk’s picture

Also consider the new Previous/Next API which is likely to be much better performing (though may not yet have any custom features you want). However if the basics are what you need and you want it really fast, then check it out.

christopherareed’s picture

I did stumble on that as well. Would you be able to explain it to me a little bit? How/where would I implement that code? Sorry if I'm being extremely novice right now, just trying to learn as I go.

dnewkerk’s picture

The module to install is http://drupal.org/project/prev_next ... so far as what it does, I think the best example is the example site which the module was created initially to help. Click on any of the images in the main content area which will bring you to that node. Then notice near the bottom of the page an area showing Previous and Next links as well as Image previews. The PHP snippets it mentions on the project page would go in your node.tpl.php (or the node-your_type.tpl.php if you made custom ones). The previous/next list includes all nodes of that specific content type (which are not necessarily in order of node ID... e.g. could be node 23, then node 27, if the nodes between are of a different content type).

It is fast because the results are indexed ahead of time. On the other hand Custom Pagers module is more flexible since you can use Views or custom PHP to create any kinds of list of nodes you want... however if the site has a large quantity of nodes, this kind of query will get "very" slow, and Custom Pagers doesn't have any indexing functionality.

Hope this helps.

christopherareed’s picture

This helps tremendously, thank you! That's exactly what I want.

Playing around with it on our site now, thanks again (thanks to everyone who responded too!).

christopherareed’s picture

Hm have a sec to troubleshoot? I followed both the documentation and the readme.txt and nothing is showing up.
http://www.hotautoweb.com/classics/1959-chevy-impala-sport-coupe-2006-au...

If you look below the bookmarks you can see the bullets for the prev/next where the code is inserted.

I enabled the module. I enabled it and indexed for the content type. I added the function to my template.php as the readme instructed. I inserted the php in my proper node-type.tpl.php file. Am I missing something?

christopherareed’s picture

Since the words 'Next' or 'Previous' aren't even being displayed, which is apart of the function, makes me think I'm not calling it right? Or have something in the wrong place?

christopherareed’s picture

Alright, I've made it so it's printing the prev/next $nid's it finds.. so it is working properly from that perspective. Now to just get it to print the link/thumbnail.. right?

EDIT: Editing so I stop bumping this, but I figured it out if anyone else ever needs help or stumbles on this node someday. I needed to change a few things in the function added to template.php.

sziszcsi’s picture

Could you please describe what was the problem with the displaying the "previous" and "next" links?
I have copied the function into the template.php and I have copied the other code into the node.tpl.php files of the them according to the readme.txt file but only the points are visible. I have re-indexed the nodes I would like to display but nothing has happened. After that I put the "code" into a custom block but I get the same result. Is something wrong with the code or function, or did I something wrong?