Is it possible to use basic navigation (previous/next) on each node (single node view) so that you can access the previous/next node of the same category? Is there a module for that?

Comments

dman’s picture

The module for that is probably 'book' which creates absolute heirarchical structure.

However, the problem you are looking at is "What is 'next' after this node when viewed in different contexts?"

If you can explain the behaviour you expect in one sentence or less, there may be a reasonable snippet for you. If not, it will require deep thought.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

jiakomo’s picture

As I said, next/previous should always navigate to next/previous nodes of the same category (as is their standard order in category view, which is, I think, chronological).

For example:

-category1
--node1
--node2
--node3
--node4

Previous/next of node2 would be node1 and node3

dman’s picture

Unfortunately your expectation is incomplete. I know it sounds simple but there's more to it. We'll have to assume that 'next' means 'older' or 'back', which is already confusing :) - because that's what the reverse-chronological list looks like. :-/

Then... consider:

[Front Page]
Node 5 (funny, videos)
Node 4 (technical)
Node 3 (funny, pictures)
Node 2 (technical, videos)

[Funny category]
Node 5 (funny, videos)
Node 3 (funny, pictures)

[Videos category]
Node 5 (funny, videos)
Node 2 (technical, videos)

Do you see where the deep thought is now needed?
... You have just arrived at Node 5 from Google.
What node is 'next'? 4, 3, or 2?

It gets even more interesting if you have multiple or hierarchical vocabs. And then there are 'views' which are a whole 'nother set of complexity.

It's not impossible, but you'll need to figure out a way to pass context forward through pages and remember where the browser came from.
Or list "Next in {category}" which may work, but you still have to do the database lookup yourself. It's a bit tricky, but possible. With the afore-mentioned deep thought. Good luck!

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

jiakomo’s picture

You are right. You look at the big picture and I was not so specific about what I wanted.

In my case there are no multiple terms for one node. One node belongs to one and only one term. That would mean that in your example node5 would be in either "Funny" or "Videos" but not at both categories.

As I can see, there is no easy way to do this.

dman’s picture

It is a reasonable request, and it would be nice if there was a simpler answer. I could guess what you (thought you) wanted, but...
Unfortunately I always look for the "general case" solution, like you say, the big picture, and see too many problems!

I've had to explain this to clients several times before. You can get the 'next' effect, as I said, with book.module. Or even with a nodereference field. But in both cases it's gotta be done by hand.

It is, as I said, possible to invent some code that tries to do a lookup on the set of nodes tagged with the same term ... then finds the current node in that set ... then retrieves the next one.
... Or possibly a better DB query could limit on date or something.
But no, there is no easy and robust way that I know of available out there... yet.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

mooffie’s picture

Dan gave an excellent explanation about why the task isn't trivial.

Eaton's custom pagers module does some prev/next links. No D6 version yet.

jiakomo’s picture

Thank you moffie and Dan for your help!