This can be useful when calling the formatter manually or via drupal_render().

Imagine that you want to render several filefields (or an imagefiled) inside
the node content, and you want some of them inlined with the text, some as
blocks, some floated to the left, some floated to the right, all you have to
do is pass an extra class id to the formatter, and leave the rest to the CSS
layer.

I plan to use this feature in #394682: CCK fields (filefield,imagefield,emfield) and fieldgroups for Inline API with code like this:

  content_view($node, $teaser);
  // Render the first filefield, this is just an example :)
  $file = $content['field_file']['field']['items'][0]['#item'];
  // Always render the file
  $file['list'] = 1;
  // Add an extra CSS class
  $file['attributes'] = array('class' => 'float-right');
  echo drupal_render($file);
php

If the idea looks acceptable, I can work out a better patch than the one attached, and propose something similar for imagefield as well.

Thanks,
Antonio

Comments

pribeh’s picture

Bump.

ao2’s picture

PIng.

quicksketch’s picture

Status: Active » Postponed

This is unlikely to be added. FileField has been moved into Drupal core and I'd really recommend handling this in your theme anyway.

quicksketch’s picture

Status: Postponed » Closed (fixed)