field.tpl.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file field.tpl.php
  4. * Default template implementation to display the value of a field.
  5. *
  6. * This file is not used by Drupal core, which uses theme functions instead for
  7. * performance reasons. The markup is the same, though, so if you want to use
  8. * template files rather than functions to extend field theming, copy this to
  9. * your custom theme. See theme_field() for a discussion of performance.
  10. *
  11. * Available variables:
  12. * - $items: An array of field values. Use render() to output them.
  13. * - $label: The item label.
  14. * - $label_hidden: Whether the label display is set to 'hidden'.
  15. * - $classes: String of classes that can be used to style contextually through
  16. * CSS. It can be manipulated through the variable $classes_array from
  17. * preprocess functions. The default values can be one or more of the
  18. * following:
  19. * - field: The current template type, i.e., "theming hook".
  20. * - field-name-[field_name]: The current field name. For example, if the
  21. * field name is "field_description" it would result in
  22. * "field-name-field-description".
  23. * - field-type-[field_type]: The current field type. For example, if the
  24. * field type is "text" it would result in "field-type-text".
  25. * - field-label-[label_display]: The current label position. For example, if
  26. * the label position is "above" it would result in "field-label-above".
  27. *
  28. * Other variables:
  29. * - $element['#object']: The entity to which the field is attached.
  30. * - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
  31. * - $element['#field_name']: The field name.
  32. * - $element['#field_type']: The field type.
  33. * - $element['#field_language']: The field language.
  34. * - $element['#field_translatable']: Whether the field is translatable or not.
  35. * - $element['#label_display']: Position of label display, inline, above, or
  36. * hidden.
  37. * - $field_name_css: The css-compatible field name.
  38. * - $field_type_css: The css-compatible field type.
  39. * - $classes_array: Array of html class attribute values. It is flattened
  40. * into a string within the variable $classes.
  41. *
  42. * @see template_preprocess_field()
  43. * @see theme_field()
  44. *
  45. * @ingroup themeable
  46. */
  47. ?>
  48. <!--
  49. This file is not used by Drupal core, which uses theme functions instead.
  50. See http://api.drupal.org/api/function/theme_field/7 for details.
  51. After copying this file to your theme's folder and customizing it, remove this
  52. HTML comment.
  53. -->
  54. <div class="<?php print $classes; ?>"<?php print $attributes; ?>>
  55. <?php if (!$label_hidden): ?>
  56. <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  57. <?php endif; ?>
  58. <div class="field-items"<?php print $content_attributes; ?>>
  59. <?php foreach ($items as $delta => $item): ?>
  60. <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
  61. <?php endforeach; ?>
  62. </div>
  63. </div>