function template_preprocess_views_view_unformatted in Views (for Drupal 7) 8.3
Same name and namespace in other branches
- 6.3 theme/theme.inc \template_preprocess_views_view_unformatted()
- 6.2 theme/theme.inc \template_preprocess_views_view_unformatted()
- 7.3 theme/theme.inc \template_preprocess_views_view_unformatted()
Display the simple view of rows one after another
1 call to template_preprocess_views_view_unformatted()
- template_preprocess_views_view_list in theme/
theme.inc - Display the view as an HTML list element
File
- theme/
theme.inc, line 799 - Preprocessors and helper functions to make theming easier.
Code
function template_preprocess_views_view_unformatted(&$vars) {
$view = $vars['view'];
$rows = $vars['rows'];
$style = $view->style_plugin;
$options = $style->options;
$vars['row_classes'] = array();
$vars['classes'] = array();
$default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : FALSE;
$row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : FALSE;
// Set up striping values.
$count = 0;
$max = count($rows);
foreach ($rows as $id => $row) {
$count++;
if ($default_row_class) {
$vars['classes'][$id][] = 'views-row';
$vars['classes'][$id][] = 'views-row-' . $count;
}
if ($row_class_special) {
$vars['classes'][$id][] = 'views-row-' . ($count % 2 ? 'odd' : 'even');
if ($count == 1) {
$vars['classes'][$id][] = 'views-row-first';
}
if ($count == $max) {
$vars['classes'][$id][] = 'views-row-last';
}
}
if ($row_class = $view->style_plugin
->get_row_class($id)) {
$vars['classes'][$id][] = $row_class;
}
// Flatten the classes to a string for each row for the template file.
$vars['row_classes'][$id] = isset($vars['classes'][$id]) ? implode(' ', $vars['classes'][$id]) : '';
}
}