views_plugin_field_taxonomy_term_machine_name.inc in Taxonomy Machine Name 7
File
views/modules/taxonomy/views_plugin_field_taxonomy_term_machine_name.inc
View source
<?php
class views_plugin_field_taxonomy_term_machine_name extends views_handler_field {
function option_definition() {
$options = parent::option_definition();
$options['convert_underscores'] = array(
'default' => FALSE,
'bool' => TRUE,
);
return $options;
}
function options_form(&$form, &$form_state) {
$form['convert_underscores'] = array(
'#title' => t('Convert underscores 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_underscores']),
);
parent::options_form($form, $form_state);
}
function render($values) {
$value = $this
->get_value($values);
$value = $this
->sanitize_value($value);
if (!empty($this->options['convert_underscores'])) {
$value = str_replace('_', '-', $value);
}
return $value;
}
}