function theme_field


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 field.module theme_field($variables)
cle7 field.module theme_field($variables)
elmsmedia7 field.module theme_field($variables)
icor7 field.module theme_field($variables)
meedjum_blog7 field.module theme_field($variables)
mooc7 field.module theme_field($variables)

Returns HTML for a field.

This is the default theme implementation to display the value of a field. Theme developers who are comfortable with overriding theme functions may do so in order to customize this markup. This function can be overridden with varying levels of specificity. For example, for a field named 'body' displayed on the 'article' content type, any of the following functions will override this default implementation. The first of these functions that exists is used:

  • THEMENAME_field__body__article()
  • THEMENAME_field__article()
  • THEMENAME_field__body()
  • THEMENAME_field()

Theme developers who prefer to customize templates instead of overriding functions may copy the "field.tpl.php" from the "modules/field/theme" folder of the Drupal installation to somewhere within the theme's folder and customize it, just like customizing other Drupal templates such as page.tpl.php or node.tpl.php. However, it takes longer for the server to process templates than to call a function, so for websites with many fields displayed on a page, this can result in a noticeable slowdown of the website. For these websites, developers are discouraged from placing a field.tpl.php file into the theme's folder, but may customize templates for specific fields. For example, for a field named 'body' displayed on the 'article' content type, any of the following templates will override this default implementation. The first of these templates that exists is used:

  • field--body--article.tpl.php
  • field--article.tpl.php
  • field--body.tpl.php
  • field.tpl.php

So, if the body field on the article content type needs customization, a field--body--article.tpl.php file can be added within the theme's folder. Because it's a template, it will result in slightly more time needed to display that field, but it will not impact other fields, and therefore, is unlikely to cause a noticeable change in website performance. A very rough guideline is that if a page is being displayed with more than 100 fields and they are all themed with a template instead of a function, it can add up to 5% to the time it takes to display that page. This is a guideline only and the exact performance impact depends on the server configuration and the details of the website.


$variables: An associative array containing:

  • label_hidden: A boolean indicating to show or hide the field label.
  • title_attributes: A string containing the attributes for the title.
  • label: The label for the field.
  • content_attributes: A string containing the attributes for the content's div.
  • items: An array of field items.
  • item_attributes: An array of attributes for each item.
  • classes: A string containing the classes for the wrapping div.
  • attributes: A string containing the attributes for the wrapping div.

See also




Related topics

7 string references to 'theme_field'
ds_extras_ds_field_settings_alter in sites/all/modules/ulmus/ds/modules/ds_extras/ds_extras.module
Implements hook_ds_field_settings_alter().
ds_extras_ds_field_theme_functions_info in sites/all/modules/ulmus/ds/modules/ds_extras/ds_extras.module
Implements hook_ds_field_theme_functions_info().
ds_extras_field_template_settings_form in sites/all/modules/ulmus/ds/modules/ds_extras/includes/
Field template settings form
ds_extras_preprocess_field in sites/all/modules/ulmus/ds/modules/ds_extras/ds_extras.module
Implements hook_preprocess_field().
ds_extras_settings in sites/all/modules/ulmus/ds/modules/ds_extras/includes/
Menu callback: Display Suite extras settings.

... See full list

4 theme calls to theme_field()
date_all_day_date_formatter_dates_alter in sites/all/modules/ulmus/date/date_all_day/date_all_day.module
Implements hook_date_formatter_dates_alter().
hook_date_formatter_dates_alter in sites/all/modules/ulmus/date/date.api.php
Alter the dates array created by date_formatter_process().
textformatter_contrib_link_field_create_list in sites/all/modules/ulmus/textformatter/textformatter_contrib/textformatter_contrib.module
Link field listing callback.
views_handler_field::theme in sites/all/modules/ulmus/views/handlers/
Call out to the theme() function, which probably just calls render() but allows sites to override output fairly easily.
469 string references to the theme hook from theme_field()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

accessibility_reporting_report in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/accessibility_reporting.module
Report callback. Stores posted data to accessibility_reporting table.
accessibility_reporting_schema in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/accessibility_reporting.install
Implements hook_schema().
accessibility_reporting_views_data in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/views/
Implements hook_views_data().
accessibility_reporting_views_default_views in sites/all/modules/ulmus/accessibility/modules/accessibility_reporting/views/
accessibility_views_data in sites/all/modules/ulmus/accessibility/views/
@file Providing extra functionality for views.

... See full list


modules/field/field.module, line 1161
Attach custom data fields to Drupal entities.


function theme_field($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<div class="field-label"' . $variables['title_attributes'] . '>' . $variables['label'] . ':&nbsp;</div>';

  // Render the items.
  $output .= '<div class="field-items"' . $variables['content_attributes'] . '>';
  foreach ($variables['items'] as $delta => $item) {
    $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even');
    $output .= '<div class="' . $classes . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</div>';
  $output .= '</div>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . '"' . $variables['attributes'] . '>' . $output . '</div>';

  return $output;



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.