You are here

function views_megarow_preprocess_views_view_table in Views Megarow 7

Implements hook_preprocess_views_view_table().

This preprocess needs to run after the views one which defines 'row_classes'.

File

./views_megarow.module, line 169

Code

function views_megarow_preprocess_views_view_table(&$vars) {

  // Add the custom classes and attributes that identify each entity row.
  if ($vars['view']->plugin_name == 'table_megarows') {
    $vars['attributes_array']['data-view-name'] = $vars['view']->name;
    $vars['attributes_array']['data-view-display'] = $vars['view']->current_display;
    $result_entities = $vars['view']->query
      ->get_result_entities($vars['view']->result);
    foreach ($vars['result'] as $count => $result) {
      $entity = $result_entities[1][$count];
      list($entity_id) = entity_extract_ids($result_entities[0], $entity);
      $vars['row_classes'][$count][] = 'item-' . $entity_id;
    }
  }
}