views:

27

answers:

1

I've made a field using Custom Formatters (Drupal, CCK).
Now I got this PHP code to export

/**
* Implements hook_theme().
*/
function product_attribute_theme() {
  return array(
    'product_attribute_formatter_product_attribute' => array(
      'arguments' => array('element' => NULL),
    ),
  );
}

/**
* Implements hook_field_formatter_info().
*/
function product_attribute_field_formatter_info() {
  return array(
    'product_attribute' => array(
      'label' => 'Product Attribute',
      'description' => t('an Attribute of a Product'),
      'field types' => array('content_taxonomy', 'text'),
      'multiple values' => CONTENT_HANDLE_MODULE,
    ),
  );
}

function theme_product_attribute_formatter_product_attribute($element) {
  return ($element['#item']['value']);
}

I tried to add it as a module in CCK but it didn't add it to the fields, how do I do so?

A: 

The formatter you created and exported still needs to be chosen as the active formatter for your specific field, which you can do without exporting the formatter.

To do this, it really depends on where and what you wanted formatted, but in general that is likely to be a CCK field on a Node display, which can be set at the Content Types 'Display fields' page: http://[www.yoursite.com/path/to/drupal]/admin/content/node-type/[content-type]/display

Decipher

related questions