1

I am trying to alter the output of a view with a tpl.php file. My goal is to insert an image immediately after another image in the view. This should only happen for 1 result. That is to say, if the value of my array image is apple, I want to also display another image of apples. So if I have a view that returns images of fruits:

  • Grapes
  • pears
  • apple
  • peaches
  • bananas

I want to display these images:

  • Grapes
  • pears
  • apple apple1
  • peaches
  • bananas

I'm open to ideas, so far I've been trying to solve the issue programatically by creating a custom .tpl file for the view, but if a cleaner solution exists I'd be willing to give it a try.

1 Answer 1

0

I've come to the conclusion that I believe the best/easiest way to do this is by adding another field to my content type, and inserting the associated image in that field. Even though I've created a field in that content type that is only required for one piece of content.

2
  • Why don't you use something like Taxonomy. Create one for Fruit with terms for each type and add an image field. Then for your content type you add a term reference to that and pull the image via the term reference into views. That way you are re-using content and can change the image once only if need be. Commented Sep 26, 2015 at 9:43
  • Thanks, this idea would also work, however in order to keep the structure of this site consistent, I think I will still stick with the additional field. Commented Sep 28, 2015 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.