Skip to content

Instantly share code, notes, and snippets.

@junaidpv
Last active May 27, 2020 17:24
Show Gist options
  • Save junaidpv/ebdf4c59466abe7864cfb3a8f54dbd3c to your computer and use it in GitHub Desktop.
Save junaidpv/ebdf4c59466abe7864cfb3a8f54dbd3c to your computer and use it in GitHub Desktop.
Patch for drupal module views_aggregator version 8.x-1.0-beta1
diff --git a/src/Plugin/views/style/Table.php b/src/Plugin/views/style/Table.php
index 6a5ed5a..a5ba07c 100644
--- a/src/Plugin/views/style/Table.php
+++ b/src/Plugin/views/style/Table.php
@@ -121,6 +121,21 @@ class Table extends ViewsTable {
],
],
];
+
+ $form['info'][$field]['aggr_strip_tags'] = [
+ '#type' => 'checkbox',
+ '#title' => $this->t('Strip tags'),
+ '#description' => $this->t('Keep it enabled if you are not sure. Disabling it may make up more groups if its markup are dissimilar, especially having link with different href values.'),
+ '#default_value' => isset($this->options['info'][$field]['aggr_strip_tags']) ? $this->options['info'][$field]['aggr_strip_tags'] : TRUE,
+ '#states' => [
+ 'visible' => [
+ 'input[name="style_options[info][' . $field . '][has_aggr]"]' => [
+ 'checked' => TRUE,
+ ],
+ ],
+ ],
+ ];
+
// Optional parameter for the selected aggregation function.
$parameter_label = $this->t('Parameter');
$form['info'][$field]['aggr_par'] = [
@@ -155,6 +170,7 @@ class Table extends ViewsTable {
],
],
];
+
// Optional parameter for the selected column aggregation function.
$form['info'][$field]['aggr_par_column'] = [
'#type' => 'textfield',
@@ -575,11 +591,16 @@ class Table extends ViewsTable {
else {
$field_name = $field_handler->options['id'];
}
+ $strip_tags = isset($this->options['info'][$field_name]['aggr_strip_tags']) ? $this->options['info'][$field_name]['aggr_strip_tags'] : TRUE;
if (isset($this->rendered_fields[$row_num][$field_name])) {
// Special handling of rendered fields, "Global: Custom text",
// "Global: View" and custom plugin fields.
if ($render === TRUE || $this->isCustomTextField($field_handler) || $this->isViewsFieldView($field_handler) || !in_array($field_handler->getProvider(), ['views', 'webform_views'])) {
- return trim(strip_tags((string) $this->rendered_fields[$row_num][$field_name]));
+ $output = trim((string) $this->rendered_fields[$row_num][$field_name]);
+ if ($strip_tags) {
+ $output = strip_tags($output);
+ }
+ return $output;
}
// Special handling of "Webform submission data".
if ($this->isWebformNumeric($field_handler) || $this->isWebformField($field_handler)) {
diff --git a/views_aggregator.theme.inc b/views_aggregator.theme.inc
index 0973816..0ff7e29 100644
--- a/views_aggregator.theme.inc
+++ b/views_aggregator.theme.inc
@@ -61,6 +61,7 @@ function template_preprocess_views_aggregator_plugin_style_table(array &$variabl
$multicell_group[] = $form['info'][$id]['has_aggr'];
$multicell_group[] = $form['info'][$id]['aggr'];
+ $multicell_group[] = $form['info'][$id]['aggr_strip_tags'];
$multicell_group[] = $form['info'][$id]['aggr_par'];
$row[]['data'] = $multicell_group;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment