I have a taxonomy with lots of nodes in it. Each node contains a large image. I want that image to be linked to the next node within the taxnomy. How can I do this in Drupal 7?
If you are interested to use a more flexible module, Custom pagers will do the job. Overlay the "next" link above the image using CSS absolute positioning.
Please see the solution that should work !
- Hook into node view using hook_node_view by writing a custom module.
Change the image field to a image with link using below technique
- Get nid of current node using $node->nid;
- Get taxonomy term id associated with node object using this technique.
- Get all other nodes attached with same taxonomy term that you got in step 2 using taxonomy_select_nodes
- From the list of node id's that you got in step 3 check the node id which is just greater than $node->nid and store it in variable $next_nid
- Form a link using l function that should be markup for image field.
$overrided_image_field_value = l($image, 'node/' . $next_nid, array('html' => TRUE));
That should do the work !
I would use the Views Slideshow module to have a view block with all the nodes belonging to the taxonomy term that is being viewed at the time. Aspects such as adding next/previous links are 'easy' using views slideshow. For node that contain large images this module should be more than apt for the job.The link should get you started.