summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-12-12 20:16:03 +0000
committerDries Buytaert <dries@buytaert.net>2009-12-12 20:16:03 +0000
commit6a13eb22fc5c7c2a27d6c18e8ec99493f1566350 (patch)
tree4b7a581e8e459fe8f00a56920165a0c6e9a5aa3f /modules/taxonomy/taxonomy.module
parentd0355f72ca75af0b9320a4560b14716195963a57 (diff)
downloadbrdo-6a13eb22fc5c7c2a27d6c18e8ec99493f1566350.tar.gz
brdo-6a13eb22fc5c7c2a27d6c18e8ec99493f1566350.tar.bz2
- Patch #657828 by yched: make hook_field_formatter() act on all field values.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module46
1 files changed, 22 insertions, 24 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 1eb295d39..a15e7b4ba 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -1087,16 +1087,10 @@ function taxonomy_field_formatter_info() {
'taxonomy_term_link' => array(
'label' => t('Link'),
'field types' => array('taxonomy_term'),
- 'behaviors' => array(
- 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
- ),
),
'taxonomy_term_plain' => array(
'label' => t('Plain text'),
'field types' => array('taxonomy_term'),
- 'behaviors' => array(
- 'multiple values' => FIELD_BEHAVIOR_DEFAULT,
- ),
),
);
}
@@ -1104,34 +1098,38 @@ function taxonomy_field_formatter_info() {
/**
* Implements hook_field_formatter().
*/
-function taxonomy_field_formatter($object_type, $object, $field, $instance, $langcode, $display, $items, $delta) {
- $item = $items[$delta];
+function taxonomy_field_formatter($object_type, $object, $field, $instance, $langcode, $items, $display) {
+ $element = array();
switch ($display['type']) {
case 'taxonomy_term_link':
- // @todo Remove this when "node_build() does not call
- // field_attach_prepare_view()" bug is fixed.
- // See http://drupal.org/node/493314.
- if (!isset($item['taxonomy_term'])) {
- $item['taxonomy_term'] = taxonomy_term_load($item['tid']);
+ foreach ($items as $delta => $item) {
+ // @todo Remove this when "node_build() does not call
+ // field_attach_prepare_view()" bug is fixed.
+ // See http://drupal.org/node/493314.
+ if (!isset($item['taxonomy_term'])) {
+ $item['taxonomy_term'] = taxonomy_term_load($item['tid']);
+ }
+ $term = $item['taxonomy_term'];
+ $element[$delta] = array(
+ '#type' => 'link',
+ '#title' => $term->name,
+ '#href' => 'taxonomy/term/' . $term->tid,
+ );
}
- $term = $item['taxonomy_term'];
- $result = array(
- '#type' => 'link',
- '#title' => $term->name,
- '#href' => 'taxonomy/term/' . $term->tid,
- );
break;
case 'taxonomy_term_plain':
- $term = $item['taxonomy_term'];
- $result = array(
- '#markup' => check_plain($term->name),
- );
+ foreach ($items as $delta => $item) {
+ $term = $item['taxonomy_term'];
+ $element[$delta] = array(
+ '#markup' => check_plain($term->name),
+ );
+ }
break;
}
- return $result;
+ return $element;
}
/**