We currently have duplicate code to handle field display :
- content_field('view') for regular node display
- single field displayed through Views
- single field displayed through Panels

Each instance currently uses its own custom code to account for the various display options (label, formatter...), and generates its own flavored HTML. This is going to get worse if/when we add further display options like formatter settings or multiple values options (li, ul, comma-separated...).

I committed the attached patch, that adds an API function to display a single field, fully themed with label and multiple values. It internally uses content_field('view'), so that we have one centralized mechanism to display a field (we still have content_format() to output single values). This also means that the output uses the existing content-field.tpl.php templates.

I'm about to commit an adapted patch for #323681: Adding CCK Fields to Panels Pages using this new function.

CommentFileSizeAuthor
content_view_field.patch4.31 KByched
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Forgot to add : We should IMO use the same function for Views fields / 'group multiple values' option (content_handler_field_multiple:render() )
This should induce no visual change in most cases, but will change the structure of the HTML output and thus possibly break custom styling, so we should do this before rolling 2.0.

I'll do that asap if no-one objects.

yched’s picture

Hm. Fields display in Views is going to be a little trickier because of the 'link to node' option, and the way Views displays its labels which doesn't map well with our field template, so it's going to have to wait a little...

Status: Fixed » Closed (fixed)

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