Check if checkbox field is checked (Drupal 7 theming)
Recently, I need the following features for one of client Drupal 7 site:
There is one content type that requires option to change the layout just by using checkbox, what is needed is an inline CSS that are added automatically if the checkbox is checked, so the CSS is added to node.tpl.php directly.
Checkbox created using Field module, the Boolean. Here's the code that I add:
<?php if (!empty($content['field_boolean']['#items']['value']) == '1'): ?> <style type="text/css"> // some css style here... </style> <?php endif; ?>
Change the field_boolean with your field name.