You can create custom formatters for CCK Fields. The code is pretty simple.

This doesn’t remove the extranious wrapper divs that cck creates by default, tho. To remove those I’m also using a modified content-field.tpl.php file.

Both the formatter module and the content-field.tpl.php are attached.

UPDATE: new content-field.tpl.php file. w/ more explicit conditionals

UPDATE: new content-field.tpl.php file. adds incremental field-item classes for multiple fields (see: http://langley.canarypromotion.com/knowledge/incremental-classes-when-gr…)

customformats.module

<?php

/**
* Implementation of hook_field_formatter_info().
*/
function customformats_field_formatter_info() {
  return array(
   
'pyp_callout' => array('label' => t('PYP Callout markup'),
     
'field types' => array('text'),
     
'multiple values' => CONTENT_HANDLE_CORE),
  );
}

/**
* Implementation of hook_theme().
*/
function customformats_theme() {
  return array(
   
'customformats_formatter_pyp_callout' => array(
     
'arguments' => array('element' => NULL),
     
'function' => 'theme_customformats_pyp_callout'),
  );
}

/**
* Theme function to display showtimes.
*/
function theme_customformats_pyp_callout($element) {
 
$output = '<div class="callout">'. $element['#item']['value'] .'</div>';
  return
$output;
}

?>

content-field.tpl.php

<?php if (!$field_empty) : ?>
<?php if ($field['display_settings']['full']['format'] == 'pyp_callout') : ?>
<?php $count = 1;
    foreach (
$items as $delta => $item) :
      if (!
$item['empty']) : ?>

      <?php print $item['view'] ?>
      <?php $count++;
      endif;
    endforeach;
?>

<?php else: ?>
<div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">
  <?php if ($label_display == 'above') : ?>
    <div class="field-label"><?php print t($label) ?>:&nbsp;</div>
  <?php endif;?>
  <div class="field-items">
    <?php $count = 1;
            foreach (
$items as $delta => $item) :
              if (!
$item['empty']) : ?>

        <div class="field-item <?php print ($count % 2 ? 'odd' : 'even') ?>">
          <?php if ($label_display == 'inline') { ?>
            <div class="field-label-inline<?php print($delta ? '' : '-first')?>">
              <?php print t($label) ?>:&nbsp;</div>
          <?php } ?>
          <?php print $item['view'] ?>
        </div>
      <?php $count++;
              endif;
            endforeach;
?>

  </div>
</div>
  <?php endif; ?>
<?php endif; ?>

Add your comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.