0

Is there a way in views to return 1 node that was published before the current node being viewed and the 1 node after?

Currently I have a view using a contextual filter which is the current NID from URL but I can't find a way to pass that to the filter criteria.

Is it possible? It can be split in to 2 views if needed so in 1 I get the previous node and the other I get the next one.

e.g.

current nid = 2

View returns 1, 3

3
  • Do you want to get links for the nodes or entire nodes ? – mohit_rocks Sep 17 '12 at 10:54
  • In the view it'll be pulling out fields. – Alex Older Sep 17 '12 at 11:56
  • fields of nodes ? If you want fields of nodes then my answer below will provide function to fetch previous and next nid also. Use nid and you can fetch desired fields. – mohit_rocks Sep 17 '12 at 12:22
0

You can use Previous/Next API to get the previous and next nodes of particular nodes. It also provides Views plugin to display Previous/Next links in View.

2
  • did what I needed it to do. Documentation is a little thin on the ground – Alex Older Sep 17 '12 at 15:16
  • Can you explain how to get this option in views.there is no extra options in views related to the prev/next api. – Aparna pc Oct 31 '13 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.