Projet

Général

Profil

Paste
Télécharger (4,69 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / themes / adaptivetheme / at_core / templates / field.tpl.php.txt @ 74f6bef0

1
<?php
2
/**
3
 * This is a copy of cores field.tpl.php modified to support HTML5. The main
4
 * difference to Drupal core is that field labels are treated like headings. In
5
 * the context of HTML5 we need to account for sectioning, so this template, like
6
 * is counterpart adaptivetheme_field() conditionally supplies the top level
7
 * element as either <section> (field label is showing) or <div> (field label
8
 * is hidden). "Hidden labels" is a misnomer and implies they are output and
9
 * hidden via CSS - not so, if a label is hidden it does not print.
10
 *
11
 * Additionally field labels are wrapped in h2 elements to improve the outline.
12
 *
13
 * Useage:
14
 * This file is not used by default by Adaptivetheme which is why this is a text
15
 * file - it is here to serve as an example if you want to override field
16
 * templates using suggestions.
17
 *
18
 * Adaptivetheme overrides theme_field() to achieve the same markup you see
19
 * here because functions are 5 times faster than templates. theme_field() is
20
 * called often in Drupal 7 sites so we want to keep things as fast as possible.
21
 *
22
 * Taxonomy Fields:
23
 * Adaptivetheme outputs taxonomy term fields as unordered lists - it
24
 * does this in adaptivetheme_field__taxonomy_term_reference().
25
 *
26
 * Image Fields:
27
 * Image fields are overridden in adaptivetheme_field__image(), instead of
28
 * the regular div container for images we use <figure> from HTML5.
29
 * The template can print captions also, using the <figcaption> element, again
30
 * from HTML5. You need to enable the "Image" theme settings in "Site Tweaks"
31
 * to enable and configure the captioning features. Captions use the #title
32
 * field for the caption text, so you must have titles enabled on image fields
33
 * for this to work.
34
 *
35
 * Adaptivetheme variables:
36
 * - $field_view_mode: The view mode so we can test for it inside a template.
37
 * - $image_caption_teaser: Boolean value to test for a theme setting.
38
 * - $image_caption_full: Boolean value to test for a theme setting.
39
 * - $is_mobile: Mixed, requires the Mobile Detect or Browscap module to return
40
 *   TRUE for mobile.  Note that tablets are also considered mobile devices.  
41
 *   Returns NULL if the feature could not be detected.
42
 * - $is_tablet: Mixed, requires the Mobile Detect to return TRUE for tablets.
43
 *   Returns NULL if the feature could not be detected.
44
 *
45
 * Available variables:
46
 * - $items: An array of field values. Use render() to output them.
47
 * - $label: The item label.
48
 * - $label_hidden: Whether the label display is set to 'hidden'.
49
 * - $classes: String of classes that can be used to style contextually through
50
 *   CSS. It can be manipulated through the variable $classes_array from
51
 *   preprocess functions. The default values can be one or more of the
52
 *   following:
53
 *   - field: The current template type, i.e., "theming hook".
54
 *   - field-name-[field_name]: The current field name. For example, if the
55
 *     field name is "field_description" it would result in
56
 *     "field-name-field-description".
57
 *   - field-type-[field_type]: The current field type. For example, if the
58
 *     field type is "text" it would result in "field-type-text".
59
 *   - field-label-[label_display]: The current label position. For example, if
60
 *     the label position is "above" it would result in "field-label-above".
61
 *
62
 * Other variables:
63
 * - $element['#object']: The entity to which the field is attached.
64
 * - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
65
 * - $element['#field_name']: The field name.
66
 * - $element['#field_type']: The field type.
67
 * - $element['#field_language']: The field language.
68
 * - $element['#field_translatable']: Whether the field is translatable or not.
69
 * - $element['#label_display']: Position of label display, inline, above, or
70
 *   hidden.
71
 * - $field_name_css: The css-compatible field name.
72
 * - $field_type_css: The css-compatible field type.
73
 * - $classes_array: Array of html class attribute values. It is flattened
74
 *   into a string within the variable $classes.
75
 *
76
 * @see template_preprocess_field()
77
 * @see theme_field()
78
 * @see adaptivetheme_preprocess_field()
79
 * @see adaptivetheme_field()
80
 * @see adaptivetheme_field__taxonomy_term_reference()
81
 * @see adaptivetheme_field__image()
82
 */
83
?>
84
<<?php print $tag; ?> class="<?php print $classes; ?>"<?php print $attributes; ?>>
85

    
86
  <?php if (!$label_hidden) : ?>
87
    <h2 class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp; XXXX</h2>
88
  <?php endif; ?>
89

    
90
  <div class="field-items"<?php print $content_attributes; ?>>
91
    <?php foreach ($items as $delta => $item) : ?>
92
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>>
93
        <?php print render($item); ?>
94
      </div>
95
    <?php endforeach; ?>
96
  </div>
97

    
98
</<?php print $tag; ?>>