#1102952 by joachim: Add option to term fields to output with spaces converted to...
authorDaniel Wehner
Sat, 26 Nov 2011 20:09:47 +0000 (21:09 +0100)
committerDaniel Wehner
Sat, 26 Nov 2011 20:09:47 +0000 (21:09 +0100)
modules/taxonomy/views_handler_field_taxonomy.inc

index ed9ac97..0093b04 100644 (file)
@@ -20,6 +20,7 @@ class views_handler_field_taxonomy extends views_handler_field {
   function option_definition() {
     $options = parent::option_definition();
     $options['link_to_taxonomy'] = array('default' => FALSE);
+    $options['convert_spaces'] = array('default' => FALSE);
     return $options;
   }
 
@@ -34,6 +35,12 @@ class views_handler_field_taxonomy extends views_handler_field {
       '#type' => 'checkbox',
       '#default_value' => !empty($this->options['link_to_taxonomy']),
     );
+    $form['convert_spaces'] = array(
+      '#title' => t('Convert spaces in term names to hyphens'),
+      '#description' => t('This allows links to work with Views taxonomy term arguments.'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['convert_spaces']),
+    );
   }
 
   /**
@@ -50,6 +57,11 @@ class views_handler_field_taxonomy extends views_handler_field {
       $this->options['alter']['make_link'] = TRUE;
       $this->options['alter']['path'] = taxonomy_term_path($term);
     }
+
+    if (!empty($this->options['convert_spaces'])) {
+      $data = str_replace(' ', '-', $data);
+    }
+
     return $data;
   }