I have created a view of type Term that lists all the taxonomy terms plus each term's image. This works. But now I want to wrap the images in a link that links to another view. I am trying to use the customfield: PHP Code field to build up an html string containing the image and the link. The only bit that I cant figure out is how to get the url of the image.

If i do print_r( $data); I get...

stdClass Object ( [tid] => 7 
[term_data_name] => Old Edinburgh 
[term_data_vid] => 2 
[term_image_tid] => 7 ) 

And the sql query is...

SELECT DISTINCT(term_data.tid) AS tid,
   term_data.name AS term_data_name,
   term_data.vid AS term_data_vid,
   term_image.tid AS term_image_tid
 FROM term_data term_data 
 LEFT JOIN term_node term_node ON term_data.tid = term_node.tid
 INNER JOIN node node_term_node ON term_node.vid = node_term_node.vid
 LEFT JOIN term_image term_image ON term_data.tid = term_image.tid
  GROUP BY tid

You shouldn't use a PHP code field, rather you can use the Image URL formatter module to create a image URL field, exclude it from display, & then use that image URL field to feed into a Global: Custom text field with your own custom img & a markup.

  • Hi, thanks but this is Drupal 7 only. Apr 30 '15 at 20:21

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.