You are here

function views_aggregator_replace in Views Aggregator Plus 8

Same name and namespace in other branches
  1. 7 views_aggregator_functions.inc \views_aggregator_replace()

Aggregates a field group as a word, phrase or number.

Parameters

array $groups: An array of groups of rows, each group indexed by group value.

object $field_handler: The handler for the view column.

string $replace_text: An optional parameter, specifying the replacement text to use.

string $column_label: An optional parameter, specifying a label placed the bottom of the column.

Return value

array An array of values, one for each group and one for the 'column'.

1 string reference to 'views_aggregator_replace'
views.view.va_test_style_table.yml in tests/modules/views_aggregator_test_config/test_views/views.view.va_test_style_table.yml
tests/modules/views_aggregator_test_config/test_views/views.view.va_test_style_table.yml

File

./views_aggregator_functions.inc, line 606
views_aggregator_functions.inc

Code

function views_aggregator_replace(array $groups, $field_handler, $replace_text = NULL, $column_label = NULL) {
  $values = [];
  foreach ($groups as $group => $rows) {
    if (isset($replace_text)) {
      $values[$group] = $replace_text;
    }
    if (count($rows) > 1 && isset($replace_text)) {

      // With more than one field in a group the fields no longer belong to one
      // particular entity. Cannot support hyper-linking, so switch it off.
      // Unfortunately this applies to the entire column.
      unset($field_handler->options['link_to_node']);
    }
  }
  if (isset($column_label)) {
    $values['column'] = $column_label;
  }
  return $values;
}