You are here

function asset_widget_preprocess_views_view_unformatted__asset_widget_search in Asset 7

Preprocess variables for views-view-unformatted--asset-widget-search.tpl.php.

See also

views-view-unformatted--asset-widget-search.tpl.php

File

modules/asset_widget/asset_widget.module, line 992
Code for the Asset widget module.

Code

function asset_widget_preprocess_views_view_unformatted__asset_widget_search(&$vars) {

  // Add specific classes.
  if ($vars['view']->result) {
    foreach ($vars['view']->result as $key => $result) {

      // Default classes.
      $classes = array(
        'item',
        'item-drag',
      );
      if ($key == 0) {
        $classes[] = 'first';
      }

      // Because of slice we should load asset here, to know it's type.
      if ($result->aid && ($asset = asset_load($result->aid))) {
        $classes[] = "match-{$asset->type}";
      }
      $vars['wrapper_classes'][$key] = implode(' ', $classes);
    }
  }
}