Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 300833

Let the 'Transform dashes in URL to spaces in term name filter values' find terms that should contain the dash

$
0
0

Problem/Motivation

Follow up to #2710407: Option for 'Transform dashes in URL to spaces in term name filter values' on term arguments doesn't affect the query

If you have a term "co-worker" and you enable 'Transform dashes in URL to spaces in term name filter values', no matches will be found because the dash will be removed.

So we need to figure out how to handle the case where you have both terms with spaces and terms with dashes, since now it only works with one or the other.

Also need to figure out how to handle this when you have both "co worker" and "co-worker" as terms.

Steps to Reproduce problem

Below step is for Drupal standard installation

  1. Create a term "co-worker" in the "Tags" vocabulary
  2. Now lets add a view to show "article" type contents
  3. Under the "ADVANCED" tab add a relationship Taxonomy term referenced from field_tags
  4. Click on Add and configure relationships. and then click on Apply
  5. add_relationships

  6. Now under the "ADVANCED" tab add a Contextual Filter "Name" under "Taxonomy term" category.
  7. add_contextual_filters

  8. Click on Add and configure contextual filters
  9. Under WHEN THE FILTER VALUE IS NOT IN THE URL section, select Display contents of "No results found" option.
  10. Now check on Transform dashes in URL to spaces in term name filter values option.
  11. when_filter_is_not_in_url

  12. In the "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED" section Check Specify validation criteria option and in the "Validator" dropdown select Taxonomy term name option.
  13. contexttual_validator

  14. Click on Apply and Save the view.
  15. Now Under preview section type co-worker in the input box "Preview with contextual filters:" and click on "Update preview" button.
  16. filter_with_no_result

  17. You won't get any result

Proposed resolution

If the 'Transform dashes in URL to spaces in term name filter values' checkbox is set, search for terms that match either a space or a dash for any dashes in the argument value.

If multiple terms match, use the most recently created term.

Remaining tasks

  1. UX review of '#description' => $this->t('You can have both terms with spaces and terms with dashes like "co worker" and "co-worker". Then only the last created term will be matched.'),
    • Is that the behavior we want? Should it be "last" term, "first" term, other?
    • Is that description text good?
    • As per the Drupal Usability Meeting 2020-06-23 Update the description text to
      If there are terms with spaces and terms with dashes, like "co worker" and "co-worker", then only the last created term will be matched.
    • Also for reasons of backwards compatibility. Site builders have been dealing with the existing behavior for years, and expect that some sites have gone to a lot of trouble to work around the current behavior. It would be more comfortable with first trying the current behavior: for example, matching "co worker" but not "co-worker". If that fails, then look for matches with any combination of spaces and dashes.
  2. Other reviews / refinements.
  3. review below points has suggested

  4. RTBC.
  5. Commit.

User interface changes

Adds this description to the 'Transform dashes in URL to spaces in term name filter values' checkbox on the TermName views argument validator options form:

If there are terms with spaces and terms with dashes, like "co worker" and "co-worker", then only the last created term will be matched.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.


Viewing all articles
Browse latest Browse all 300833

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>