Trying to display a views list with order based upon current node being viewed I have a view block which shows lists of content type "news" which displays in a sidebar showing only the node title for users to peruse.

There are about 150 such "news" nodes and so I use pagitation.

These "news" nodes are completely linear. You always want to read them in order. So if you read node/20, you must read node/21 next, then node/22 etc.

I would like the view block in the sidebar to display the titles of 2 nodes BEFORE and AFTER the current node. So, if I went to node/20, I would like the view block to display:


Title of node/18
Title of node/19
Title of node/20 (current node being viewed)
Title of node/21
Title of node/22


I was hoping for some pointers as to how I might achieve this. All things that I've tried thus far have proved futile.

Thanks.
In your View, under Block Display, go to:

Advanced-> Contextual filters (Add)->Content: NID

In the "When the filter value is NOT available" option select: 

Provide default value-> PHP Code

and add the following code:

if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  $nodeid = arg(1);
  $result = strval($nodeid-2) . "+" . strval($nodeid-1) . "+" . strval($nodeid) . "+" . strval($nodeid+1) . "+" . strval($nodeid+2);
  return $result;
}


Last but not least, under "More", select the option: "Allow multiple values"