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?

  • Are you displaying details using views or you want above functionality in node landing page ?
    – Anil Sagar
    Sep 26 '12 at 12:36
  • I want it on the node's landing page
    – Ruriko
    Sep 26 '12 at 12:45

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

    1. Get nid of current node using $node->nid;
    2. Get taxonomy term id associated with node object using this technique.
    3. Get all other nodes attached with same taxonomy term that you got in step 2 using taxonomy_select_nodes
    4. 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
    5. 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.

  • I don't really want to apply a slideshow effect to my images cause I'm trying to make a comic site
    – Ruriko
    Sep 26 '12 at 12:33

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.