0

I want to print a CCK field (we'll call it CCK field "A") only if the value of another CCK field (we'll call it CCK field "B") matches a string. CCK field "B" is a select-list field with two options: "red" and "blue". I'd like to display the value of CCK field "A" only if the value of CCK field "B" is "blue". If the value is "red", then CCK field "A" should not be displayed at all.

How can I do so?

Thanks!

2

THIMK! Test the value of Field B before printing Field A.

<?php 
if(isset($node->field_field_b['und'][0]['value']) && ($node->field_field_b['und'][0]['value'] == 'blue')) { 
    if(isset($node->field_field_a['und'][0]['value'])) {
          print $node->field_field_a['und'][0]['value'];
    }
  }
 ?>
|improve this answer|||||
  • Great. Happy to help. – Triskelion Jun 10 '13 at 16: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.