(sorry for posting this many questions in such a short time - this is the last for a while I promise!)

Basically, using contemplate how can I stop fields being displayed if the user has not entered a value?

I have several fields that I created using CCK that are optional, however when I display them using contemplate the header still shows up no matter if a value has been entered, or left out...

Comments

eviljoker7075’s picture

This is the code I have tried, which doesn't work:

<?php if ($node->field_leastfavouritetrack) { ?><?php print $node->field_leastfavouritetrack?><?php } ?>

marcvangend’s picture

Check the list with 'body variables' that contemplate provides... You will see that $node->field_leastfavouritetrack is an array. So even if the keys within that array are empty, the array itself is not, so it will allways return TRUE.
Try this:
<?php if ($node->field_leastfavouritetrack[0]['view']) { print $node->field_leastfavouritetrack[0]['view'] } ?>
(and note that you can delete php closing and opening tags when they touch eachother like this: ?><?php)