Actually there is a problem with taxonomy terms that have spaces.

For example, something like

/myview/cms drupal+php+web will be interpreted like

cms+drupal+php+web

wich means that 'cms drupal' will never be selected.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dagmar’s picture

Status: Active » Needs review
FileSize
3.26 KB

Here is the patch

dawehner’s picture

Status: Needs review » Needs work

Oh if i apply this patch i get

patch: **** Only garbage was found in the patch input.
dagmar’s picture

Status: Needs work » Needs review
FileSize
3.18 KB

Here is the re-roll.

SgtPepper’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

Could this be ported to version 7?
thanks!

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev

The current patch is against 6.x, so please keep it there.

If you want to help please test the patch there, i'm pretty sure then it's not that hard to port to 7.x-3.x

dagmar’s picture

Title: Allow taxonomy terms with spaces in arguments with multiple terms » Allow to use multiple arguments with spaces
Version: 6.x-3.x-dev » 7.x-3.x-dev
FileSize
3 KB

Here is the 7.x-3.x version. Changed the title since it works for other kinds of arguments besides taxonomy terms.

dagmar’s picture

After some testing I found this doesn't work for arguments with dashes on it

Now this is working properly.

Dashes in arguments have to be encoded using a double dash, like this:

my_view/Consectetuer--Decet+At-Fere-Iusto-Luptatum

This will filter by "Consectetuer-Decet" OR "At Fere Iusto Luptatum"

Also, would be nice to fix #1042546: Allow to replace spaces by dashes in links to encode a dash into a double dash.

dagmar’s picture

Here is the 6.x-3.x version.

dawehner’s picture

Status: Needs review » Needs work

When testing this patch i saw that '-' are converted to '/' if you don't have checked "replace spaces with -' this sounds like a bug.
Shouldn't be to hard to fix.

One additional thing i saw is that

+++ b/includes/handlers.incundefined
@@ -1049,15 +1049,21 @@ function views_break_phrase_string($str, &$handler = NULL) {
+  if (strpos($str, ' ') !== FALSE) {

this doesn't allow to use "+" anymore

dagmar’s picture

Status: Needs work » Needs review
FileSize
4.59 KB
4.85 KB

Thanks for the review @dereine.

Well I did some changes to the patch. There was some problems with strings like "Drupal - Wordpress".

So, this patch allows to filter taxonomy terms (and probably titles or other strings) like:

  • Drupal & Wordpress
  • Drupal 7.x-3.x
  • Drupal-cms
  • Drupal cms

And the combination of thos strings in something like

Drupal- CMS+Wordpress- &- Others

I tried to write test to check this but I didn't found an easy way to add taxonomy terms to nodes using simpletest. Sorry.

dawehner’s picture

+++ b/handlers/views_handler_field.incundefined
@@ -1197,7 +1197,8 @@ If you would like to have the characters %5B and %5D please use the html entity
+        $path = str_replace(' ', '- ', $path);

I totally get this change, you want to have a way to distinct between "-" and "--", though i'm wondering whether people actually expect to have " " to "-". Wouldn't it be possible to use -- to "\", then "-" to "/" and then "\" to "-", so for the actual output nothing changes.

I'm trying to write a simpletest without taxonomy terms, but with plain title strings.

tim.plunkett’s picture

Triggering the testbot.

Status: Needs review » Needs work

The last submitted patch, 1027458.views-7.x-3.x.10.patch, failed testing.

burgs’s picture

Would it be a crazy time to suggest that we replace the OR operator from a + to something like a | or something that isn't a somewhat special character in urls?

sokrplare’s picture

Issue summary: View changes

+1 for comment #14!

Looks like the D7 patch in #10 no longer applies (not too much surprise there, but just to save others some time trying) - the issues are with includes/handlers.inc.

dawehner’s picture

Issue tags: +Needs tests

In general we certainly needs tests here, especially if we want to get this into D8 as well.

Would it be a crazy time to suggest that we replace the OR operator from a + to something like a | or something that isn't a somewhat special character in urls?

The problem, even it might work, is that we aren't allowed to change existing behavior. This means we have to support still both usecases.

  1. +++ b/handlers/views_handler_argument_string.inc
    @@ -181,6 +178,13 @@ class views_handler_argument_string extends views_handler_argument {
    +        $this->value[$item] = strtr(strtr($value, '/', ' '), '--', '-');
    
    @@ -233,7 +237,7 @@ class views_handler_argument_string extends views_handler_argument {
    +      $value =  strtr(strtr($value, '/', ' '), '--', '-');
    
    @@ -243,19 +247,23 @@ class views_handler_argument_string extends views_handler_argument {
    +        $this->value[$item] = strtr(strtr($value, '/', ' '), '--', '-');
    

    Given that we do the same in several places, we should move that to a function.

  2. +++ b/handlers/views_handler_field.inc
    @@ -1197,7 +1197,8 @@ If you would like to have the characters %5B and %5D please use the html entity
           if (!empty($alter['replace_spaces'])) {
    -        $path = str_replace(' ', '-', $path);
    +        $path = str_replace('-', '--', $path);
    +        $path = str_replace(' ', '- ', $path);
           }
    

    In general I do prefer to have both patches in one place, tbh.

imclean’s picture

Status: Needs work » Needs review
FileSize
2.04 KB

Coming in late here, but could this simply be an option instead? Here's an example for string contextual filters which provides an option to preserve spaces. Default is the current behaviour.

imclean’s picture

Fix typo, whitespace and some code.

ladybug_3777’s picture

There's been movement on this issue on a related post: https://www.drupal.org/node/1534720

Chris Matthews’s picture

The 4 year old patch in #18 to views_handler_argument_string.inc still applies cleanly to the latest views 7.x-3.x-dev and if still relevant needs to be reviewed.

Nitebreed’s picture

Status: Needs review » Reviewed & tested by the community

Stumbled upon this issue today, patch in #18 works perfectly

DamienMcKenna’s picture

A minor adjustment, to remove the trinary operator.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 22: views-n1027458-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

DamienMcKenna’s picture

eloivaque’s picture

#22 Work for me