amariotti.com

  • about
  • blog
  • modules
  • portfolio
  • resumé
  • contact
Home › Blogs › amariotti's blog

Recent blog posts

  • Moving to tumblr
  • Happy 10th Birthday, Drupal!
  • Why I'm so excited about Rule.fm!
  • Reverse NodeReference Block - Revisited
  • CS4 Keyboard Issues
  • Text Formatter Module
  • Cool Apache ReWrite Trick
  • New RSS Feed
  • Find My iPhone
  • Congratulations, Drupal!
more

Blog tags

cck design drupal drupal 6 drupal issue liquidweb module modules that I love os x random task management views
more tags

Hiding CCK Fields when using Contemplate Module

amariotti — Mon, 08/11/2008 - 15:22

At work I am building some pretty complex content driven pages with Contemplate. I have some node data being displayed in the main content area and the rest in a dynamic block using Views Arguments. To keep a better handle on the data being displayed I am the Contemplate module, which I have found to be an extraordinary module for what it can do.

I ran into an issue today where I wanted to hide the label to the field if the field was empty. After some searching online and digging I couldn't really find anything, so I did a little research on my own and was able to come up with the solution. Here it is:

<?php if ($node->your_field_name[0]['view'] != ""): ?>
      <div class="field-item"><div class="your_label_class">Your label: </div><?php print $node->your_field_name[0]['view'] ?></div>
<?php endif; ?>

Be sure and replace <code>field_your_field_name</code> with your field name. Also be sure and put in your own custom css class for the label to make it your own!

So there it is!

  • cck
  • contemplate
  • tricks
  • amariotti's blog
  • 12009 reads
  • about
  • blog
  • modules
  • portfolio
  • resumé
  • contact