Add code to k2 page dependant upon extra field value 0/1


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php /* we're using php comments to make sure it is commented completely! this is the code snippet to assign the extra fields array to the variable called $custom */ ?>
  2.  
  3. <?php $custom = $this->item->extra_fields; ?>
  4.  
  5. <?php /* this is the if statement to show a block of code only if the first custom field is not empty */ ?>
  6.  
  7. <?php if(!empty($custom[0]->value)):?>
  8.  
  9. This is the code or text to show only if the first custom field is not empty. To actually output the field in here, you would add it like this:
  10.  
  11. <?php echo $custom[0]->value;?>
  12. <?php endif;?>
  13.  
  14. <?php /* to make this work for any other field, just change the number in the [square brackets]. the first field in the group is 0, second is 1, third is 2, etc. */ ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.