Hi, as the subject may suggest, I have an issue with CCK that I would like help with. What I would like is if an input field in my new content type is unused, then the field label will not be apparent. For example using the following config:

http://hazexp.googlepages.com/config.png

and using this input into one of the fields:

http://hazexp.googlepages.com/input.png

I end up getting this:

http://hazexp.googlepages.com/output.png

However, I would like 'Addons' not to appear seeing as the field is empty. Is there some way for CCK to be configured to allow this to happen?

Thanks in advance.

Comments

evanscape’s picture

interested in this solution as well. anyone?

hazexp’s picture

I really don't like having to do this but would someone please be able to help? Any assisstance would be greatly appreciated.

toma’s picture

Formatting, Hiding, and Showing Fields

http://drupal.org/node/62485

---
Drupaldemo now 5.0
http://www.drupaldemo.org

hazexp’s picture

I'm reading this, but don't know where to put any of this code, sorry for my apparent incompetence, I looked through, and tried putting the code in a few places that were mentioned, but they didn't seem to work. If you were able to help me further with this, I would be very thankful.

hazexp’s picture

I would really appreciate anyone's help on where to put this PHP code in order to hide the respective unused field.

http://drupal.org/node/62485

<?php if ($field_addon[0]['view'] > '') : ?>
<dt><label>Addon:</label></dt>
<?php foreach ($field_addon as $addon) { ?>
<dd> <?php print $addon['view'] ?> </dd>
<?php } ?>
<?php endif; ?>

I read through the documentation, but couldn't seem to work out where to put this PHP code.

toma’s picture

You need to create a template read this

http://drupal.org/node/62468

---
Drupaldemo now 5.0
http://www.drupaldemo.org

munkle’s picture

Hi hazexp,

I tried to fix this by installing the new CVS version of the content module, which managed to completely screw up my whole site, so in the end I just fixed this myself...

Its a very dodgy hack but it works fine for me. You need to open up content.module from the /modules/cck directory, and go to the very end of the file, where you'll see this:

  $output .= '<div class="field-items">';
  foreach ($items as $item) {
    $output .= '<div class="field-item">'. $item['view'] .'</div>';
  }
  $output .= '</div>';

  $output .= '</div>';

  return $output;
}

Replace it with this:

$output .= '<div class="field-items">';

  
  foreach ($items as $item) {
    $output2 = '<div class="field-item">'. $item['view'] .'</div>';	
  }
  
  $output .= $output2;
  
  $output .= '</div>';

  $output .= '</div>';
  
  if (strlen($output2) == 30)
  {
  	$output = '';
  }
  
  return $output;
}