function template_preprocess_semanticviews_view_fields in Semantic Views 7
Same name and namespace in other branches
- 6 semanticviews.theme.inc \template_preprocess_semanticviews_view_fields()
Preprocess theme function to print a single record from a row, with fields
File
- ./
semanticviews.theme.inc, line 13 - Theme for Semantic Views.
Code
function template_preprocess_semanticviews_view_fields(&$vars) {
$view = $vars['view'];
// Loop through the fields for this view.
$vars['fields'] = array();
// ensure it's at least an empty array.
foreach ($view->field as $id => $field) {
// render this even if set to exclude so it can be used elsewhere.
$field_output = $view->style_plugin
->get_field($view->row_index, $id);
$empty = $field
->is_value_empty($field_output, $field->options['empty_zero']);
if (empty($field->options['exclude']) && (!$empty || empty($field->options['hide_empty']) && empty($vars['options']['skip_blank']))) {
$object = new stdClass();
$object->content = $field_output;
if (isset($view->field[$id]->field_alias) && isset($vars['row']->{$view->field[$id]->field_alias})) {
$object->raw = $vars['row']->{$view->field[$id]->field_alias};
}
else {
$object->raw = NULL;
// make sure it exists to reduce NOTICE
}
$object->handler =& $view->field[$id];
// If Semantic Views: Fields settings havn't been saved with new fields
// this is not set and then add empty array with no values.
if (isset($vars['options']['semantic_html'][$id])) {
$semantic_html = $vars['options']['semantic_html'][$id];
}
else {
// Default empty values.
$semantic_html = array(
'element_type' => '',
'class' => '',
'label_element_type' => '',
'label_class' => '',
);
}
// Field content
$object->element_type = check_plain($semantic_html['element_type']);
$object->attributes = array();
if ($semantic_html['class']) {
$object->attributes['class'] = $semantic_html['class'];
}
// Field label
$object->label = check_plain($view->field[$id]
->label());
if (!empty($object->label)) {
$object->label_element_type = check_plain($semantic_html['label_element_type']);
$object->label_attributes = array();
if ($semantic_html['label_class']) {
$object->label_attributes['class'] = $semantic_html['label_class'];
}
}
$vars['fields'][$id] = $object;
}
}
}