1

I am using Drupal 7 together with Drupal Commerce (not Kickstart). I am using a Bootstrap theme.

I have list of products displayed in a table that I created with Views. If you click on the Title, it goes to the product content page (display). Obviously, a product has an image if one is available. What I would want to do is to have a column in the table (Image), that would print out Yes or No, depending on if the image is uploaded (available) for the product.

Is this something that can be done in Drupal?

2
  • Do want to display Yes/No in the table or product display page?
    – Ajay Reddy
    Jun 18, 2018 at 6:13
  • In the table that shows the list of all product.
    – prmz
    Jun 19, 2018 at 8:33

1 Answer 1

2

Simply add your image field. When you add it, or if you click on it if you already added it, you will see something similar to the following date field screenshot.

enter image description here

  • Click on rewrite results and put "Yes" here.

  • Click on no results behavior and put "No" here.


Is there a way to solve this in a similar way if you have a default image set - if none is uploaded a default image shows up?

In this scenario you would have to use Image URL Formatter and set the view image field formatter to display url.

Then you would simply perform a conditional check to see if the URL is equal to the default image url either using Views template file & custom code OR alternatively using Views Conditional for a zero coding solution.

2
  • Thanks. This sounds like an elegant solution. Is there a way to solve this in a similar way if you have a default image set - if none is uploaded a default image shows up?
    – prmz
    Jun 19, 2018 at 8:41
  • @prima, hehe forgot about that, just added a solution for that scenario to my answer.
    – No Sssweat
    Jun 19, 2018 at 10:58

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.