function weight_preprocess_views_view_table in Weight 7.3
Same name and namespace in other branches
- 8.3 weight.module \weight_preprocess_views_view_table()
- 7.2 weight.module \weight_preprocess_views_view_table()
Implementes hook_preprocess_views_view_table().
File
- ./
weight.module, line 147 - Provides a weight field that allows entities to be ordered.
Code
function weight_preprocess_views_view_table(&$variables) {
$weight_selector = FALSE;
// Check for a weight selector field.
foreach ($variables['view']->field as $field) {
if (isset($field->options['weight_selector'])) {
$weight_selector = TRUE;
break;
}
}
if ($weight_selector) {
// Add the tabledrag attributes.
foreach ($variables['rows'] as $key => $row) {
$variables['row_classes'][$key][] = 'draggable';
}
$table_id = 'weight-table-' . $variables['id'];
$variables['attributes_array']['id'] = $table_id;
drupal_add_tabledrag($table_id, 'order', 'sibling', 'weight-selector');
}
}