You are here

function template_preprocess_ds_row_object in Display Suite 6.2

Same name and namespace in other branches
  1. 6.3 theme/theme.inc \template_preprocess_ds_row_object()
  2. 6 theme/theme.inc \template_preprocess_ds_row_object()

Template preprocess function for theme_views_view_row_object(). We delegate the manipulation of the object to a function which every module implementing the ds_api should define.

Parameters

$vars:

File

theme/theme.inc, line 642
Theming functions for ds.

Code

function template_preprocess_ds_row_object(&$vars) {
  $options = $vars['options'];
  $vars['object'] = '';
  $vars['data_object'] = '';

  // The advanced selector searches for a function called
  // ds_views_row_adv_VIEWSNAME.
  if ($options['advanced']) {
    $build_mode = $options['build_mode'];
    $row_function = 'ds_views_row_adv_' . $vars['view']->name;
    $row_function($vars, $build_mode);
  }
  else {
    static $nrs, $grouping = array();
    $group_value_content = '';
    $view_name = $vars['view']->name . '_' . $vars['view']->current_display;

    // Keep a static number for this view.
    if (!isset($nrs[$view_name])) {
      $nrs[$view_name] = 0;
    }

    // Change the build mode per view.
    if (isset($options['changing']) && $options['changing']) {

      // Check for paging to determine the build mode.
      if (isset($_GET['page']) && isset($options['changing_fieldset']['allpages']) && !$options['changing_fieldset']['allpages']) {
        $build_mode = $options['build_mode'];
      }
      else {
        $build_mode = $options['changing_fieldset']['item_' . $nrs[$view_name]];
      }
    }
    else {
      $build_mode = $options['build_mode'];
    }

    // Call the function.
    $row_function = 'ds_views_row_' . $vars['view']->base_table;
    $row_function($vars, $build_mode);

    // Keep a static grouping for this view.
    if (isset($options['grouping']) && $options['grouping']) {
      $group_value = $vars['view']->result[$nrs[$view_name]]->{$options}['grouping_fieldset']['group_field'];
      if (!isset($grouping[$view_name][$group_value])) {
        $group_value_content = '<h2 class="grouping-title">' . $group_value . '</h2>';
        $grouping[$view_name][$group_value] = $group_value;
      }
    }

    // Grouping or not ?
    if (!empty($grouping[$view_name])) {
      if (!empty($group_value_content)) {
        $vars['data_object'] = $group_value_content;
      }
      $vars['data_object'] .= '<div class="grouping-content">' . $vars['object'] . '</div>';
    }
    else {
      $vars['data_object'] = $vars['object'];
    }

    // Increment the number for this view.
    $nrs[$view_name]++;
  }
}