Problem/Motivation

The exposed filter in views works when we separate in different properties, like separate for given and family. I don't see an option for for example both name and family to be in one exposed filter. Maybe im missing something.

Proposed resolution

Let's add another pseudo-field using exposed filter plugin that works on all properties.

Comments

Denchev created an issue. See original summary.

slashrsm’s picture

Issue summary: View changes
alan d.’s picture

Could provide a better options, but I wonder about performance:

$parts = explode($str, ' ');
foreach $part as $keyword%
  add condition (title = %key% || given = %key% || middle = %key% || family = %key% || creds = %key%)
bluegeek9’s picture

Category: Task » Support request
Status: Active » Fixed

The name_fulltext filter already exists and searches across all components (title, given, middle, family, generational, credentials) in a single LOWER(CONCAT(...)) SQL expression:

Fulltext.php
Lines 113-121

  public function query() {
    $this->ensureMyTable();
    // Don't filter on empty strings.
    if (empty($this->value[0])) {
      return;
    }
    $field = "$this->tableAlias.$this->realField";
    $fulltext_field = "LOWER(CONCAT(' ', COALESCE({$field}_title, ''), ' ', COALESCE({$field}_given, ''), ' ', COALESCE({$field}_middle, ''), ' ', COALESCE({$field}_family, ''), ' ', COALESCE({$field}_generational, ''), ' ', COALESCE({$field}_credentials, '')))";

It's wired up to the main field (not the sub-components) in name_field_views_data():

name.module
Lines 450-457

  foreach ($data as $table_name => $table_data) {
    $data[$table_name][$field_name]['filter'] = [
      'field' => $field_name,
      'table' => $table_name,
      'field_name' => $field_name,
      'id' => 'name_fulltext',
      'allow_empty' => TRUE,
    ];

How to find it in Views: When adding a filter, look for the field labeled just "Name" (or whatever the field label is), not the sub-items like "Name: Given" or "Name: Family". The sub-component entries only get field handlers (for display columns), not filter handlers — the separate given/family filters you're seeing come from Drupal core's default Views data for the individual database columns.

The name_fulltext filter supports three operators:

Contains — substring match (spaces become % wildcards, so "John Smith" matches across components)
Contains any word — OR between words
Contains all words — AND between words

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

bluegeek9’s picture

//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.