Let's say I have the following.

A view which displays videos ordered by date. A user chooses one of the videos and opens the pages (node). On this node I would like to attach a block, that would show the previous and next video in the view they came from. How would I go about setting that up? Would I just use the views module, create a block display, and pass some sort of argument that let's me know what node I'm currently on?

Any help on how to set this up will be greatly appreciated :)

thanks!
-dan

Comments

c-logemann’s picture

Hello dan,
I don't know a direct way to handle this with views UI. But you can set up a block and load the view with PHP starting in this way:

$view = views_get_view('your_view_name'); // the machine readable name of the view
$view->set_items_per_page(100); // set your maximal items if not, the default "10" is used
$view->execute();
$your_view_items = $view->result;  //you get an array with your raw views data and can work with it

Now you have the views-Items in an array. You can find the current nid in it and look for the prev and next nid in your item list to build your links.

kind regards,
Carsten

--
There is a module for that!
My company: Nodegard GmbH