public function views_accordion_style_plugin::pre_render in Views Accordion 7
Necessary to prevent markup mayhem.
Overrides views_plugin_style::pre_render
File
- ./
views_accordion_style_plugin.inc, line 216 - Provide an accordion style plugin for Views. This file is autoloaded by views.
Class
- views_accordion_style_plugin
- Implements views_plugin_style().
Code
public function pre_render($result) {
drupal_add_library('system', 'ui.accordion');
drupal_add_js(drupal_get_path('module', 'views_accordion') . '/views-accordion.js');
// No need do anything if we are using the grouped field as the header.
if ($this->options['use-grouping-header']) {
return;
}
// Find out about the header field options.
$fields = array_values($this->display->handler
->get_option('fields'));
$header_class = 'views-accordion-header';
// Add header class to first not-excluded field.
foreach ($fields as $field) {
if (!isset($field['exclude']) || $field['exclude'] == 0) {
// Setup our wrapper class.
// If the user configured its own class, set that up with our own class.
if (!empty($field['element_wrapper_class'])) {
$header_wrapper_class = $field['element_wrapper_class'] . ' ' . $header_class;
}
else {
$header_wrapper_class = $header_class;
}
// Setup the view to use our processed wrapper class.
$this->view->field[$field['id']]->options['element_wrapper_class'] = $header_wrapper_class;
// Make sure we are using a div for markup at least.
if (empty($field['element_wrapper_type'])) {
$this->view->field[$field['id']]->options['element_wrapper_type'] = 'div';
}
break;
}
}
}