Skip to content
Snippets Groups Projects

Issue/3051797

Open Panagiotis Moutsopoulos requested to merge issue/drupal-3051797:issue/3051797 into 11.x
1 file
+ 12
1
Compare changes
  • Side-by-side
  • Inline
@@ -9,7 +9,7 @@
use Drupal\views\ViewExecutable;
/**
* Field handler to display the timestamp of a comment with the count of comments.
* Field handler to display the timestamp of the last comment.
*
* @ingroup views_field_handlers
*/
@@ -25,6 +25,17 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$
$this->additional_fields['comment_count'] = 'comment_count';
}
/**
* {@inheritdoc}
*/
public function query(): void {
$this->ensureMyTable();
// Add the field.
$params = $this->options['group_type'] != 'group' ? ['function' => $this->options['group_type']] : [];
$this->field_alias = $this->query->addField(NULL, "IF({$this->tableAlias}.comment_count > 0, {$this->tableAlias}.{$this->realField}, NULL)", $this->tableAlias . '_' . $this->field, $params);
$this->addAdditionalFields();
}
/**
* {@inheritdoc}
*/
Loading