diff --git handlers/views_handler_field.inc handlers/views_handler_field.inc
index cb83a21..fbe52c6 100644
--- handlers/views_handler_field.inc
+++ handlers/views_handler_field.inc
@@ -17,6 +17,7 @@
* 'field' => fieldname); as many fields as are necessary
* may be in this array.
* - click sortable: If TRUE, this field may be click sorted.
+ * - no semantic: If TRUE, it disables the semantic output.
*/
class views_handler_field extends views_handler {
var $field_alias = 'unknown';
@@ -143,12 +144,24 @@ class views_handler_field extends views_handler {
* Return DIV or SPAN based upon the field's element type.
*/
function element_type() {
+ if ($this->options['element type']) {
+ return $this->options['element type'];
+ }
if (isset($this->definition['element type'])) {
return $this->definition['element type'];
}
return 'span';
}
+
+ /**
+ * Return the class of the field.
+ */
+ function classes() {
+ if ($this->options['class']) {
+ return $this->options['class'];
+ }
+ }
function option_definition() {
$options = parent::option_definition();
@@ -175,6 +188,8 @@ class views_handler_field extends views_handler {
'html' => array('default' => FALSE),
),
);
+ $options['class'] = array('default' => '');
+ $options['element type'] = array('default' => '');
$options['empty'] = array('default' => '', 'translatable' => TRUE);
$options['hide_empty'] = array('default' => FALSE);
$options['empty_zero'] = array('default' => FALSE);
@@ -201,6 +216,22 @@ class views_handler_field extends views_handler {
'#default_value' => $this->options['exclude'],
'#description' => t('Check this box to not display this field, but still load it in the view. Use this option to not show a grouping field in each record, or when doing advanced theming.'),
);
+ $form['element type'] = array(
+ '#prefix' => '
',
+ '#suffix' => '
',
+ '#title' => t('Element'),
+ '#type' => 'textfield',
+ '#size' => '10',
+ '#default_value' => $this->options['element type'],
+ );
+ $form['class'] = array(
+ '#prefix' => '',
+ '#suffix' => '
',
+ '#title' => t('Class attribute'),
+ '#type' => 'textfield',
+ '#size' => '30',
+ '#default_value' => $this->options['class'],
+ );
if ($this->allow_advanced_render()) {
$form['alter']['#tree'] = TRUE;
diff --git theme/theme.inc theme/theme.inc
index b053c6e..f0a6983 100644
--- theme/theme.inc
+++ theme/theme.inc
@@ -176,6 +176,7 @@ function template_preprocess_views_view_fields(&$vars) {
$object->element_type = $object->handler->element_type();
$object->class = views_css_safe($id);
+ $object->classes = $object->handler->classes();
$object->label = check_plain($view->field[$id]->label());
$vars['fields'][$id] = $object;
}
@@ -337,6 +338,11 @@ function template_preprocess_views_view_table(&$vars) {
$vars['fields'][$field] .= ' ' . views_css_safe($options['info'][$field]['align']);
}
+ // Add semantic classes
+ if ($classes = $fields[$field]->classes()) {
+ $vars['fields'][$field] .= ' ' . $classes;
+ }
+
// Render each field into its appropriate column.
foreach ($result as $num => $row) {
if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) {
diff --git theme/views-view-fields.tpl.php theme/views-view-fields.tpl.php
index bfab537..e93cd97 100644
--- theme/views-view-fields.tpl.php
+++ theme/views-view-fields.tpl.php
@@ -34,6 +34,6 @@
// $field->element_type is either SPAN or DIV depending upon whether or not
// the field is a 'block' element type or 'inline' element type.
?>
- <element_type; ?> class="field-content">content; ?>element_type; ?>>
+ <element_type; ?> class="field-content classes;?>">content; ?>element_type; ?>>
inline_html;?>>