Hey there,

I'm trying to contribute to cck_blocks. We are using content_format() to get field values formatted. Unfortunately, I'm not able to get formatted values back from content_format(), but I have to call it for each item of a field seperately. When calling content_format() with multiple values, the result is empty. I tried this for different fielt types and different formatters, but I only got data from content_format() when the module nodereference views is installed and the formatter is set to views. The other field types, I tried are: date, text and link.

As I'm not vompletely sure, if we are using content_format() correctly, I provide a snippet:
module_invoke('content', 'format', $fields[$delta], $items, $settings['formatter'], $node);

I tried to figure out, which formatter is a multiple values formatter by creating an if-statement for:
content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE

but all the formatters seem to claim, that they do "CONTENT_HANDLE_MODULE".

I hope, this is enough information. Don't hesitate to ask questions for more details.

Regards,
forschi

Comments

karens’s picture

Status: Active » Fixed

Don't use 'module_invoke', just 'content_format', as:

foreach ($node->field_name as $item) {
  print content_format('field_name', $item, 'my_formatter');
}

The formatters provided by all current modules are single value formatters and each content_format() will give you one item of a multiple value. We provided a way for a custom formatter to process multiple values if it wants to, but none of the core formatters do that.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.