You are here

function template_preprocess_views_view_row_sgrid_style in Sortable Grid Views Plugin 6

Same name and namespace in other branches
  1. 7 sgrid_theme.inc \template_preprocess_views_view_row_sgrid_style()

File

./sgrid_theme.inc, line 42
Theme functions for Sortable Grid module

Code

function template_preprocess_views_view_row_sgrid_style(&$vars) {
  $view = $vars['view'];

  // Loop through the fields for this view.
  $inline = FALSE;
  $vars['fields'] = array();

  // ensure it's at least an empty array.
  foreach ($view->field as $id => $field) {

    // render this even if set to exclude so it can be used elsewhere.
    $field_output = $view->style_plugin
      ->get_field($view->row_index, $id);
    $empty = $field_output !== 0 && empty($field_output);
    if (empty($field->options['exclude']) && (!$empty || empty($field->options['hide_empty']))) {
      $object = new stdClass();
      $object->content = $field_output;
      if (isset($view->field[$id]->field_alias) && isset($vars['row']->{$view->field[$id]->field_alias})) {
        $object->raw = $vars['row']->{$view->field[$id]->field_alias};
      }
      else {
        $object->raw = NULL;

        // make sure it exists to reduce NOTICE
      }
      $object->inline = !empty($vars['options']['inline'][$id]);
      $object->inline_html = $object->inline ? 'span' : 'div';
      if (!empty($vars['options']['separator']) && $inline && $object->inline && $object->content) {
        $object->separator = filter_xss_admin($vars['options']['separator']);
      }
      $inline = $object->inline;
      $object->handler =& $view->field[$id];
      $object->element_type = $object->handler
        ->element_type();
      $object->class = views_css_safe($id);
      $object->label = check_plain($view->field[$id]
        ->label());
      $vars['fields'][$id] = $object;
    }
  }

  // Add the row's nid to available variables for views-view-row-sgrid-style.tpl.php
  $vars['sgrid_nid'] = $view->result[$view->row_index]->nid;
}