The "Transform dashes in URL to spaces in term name filter values" option breaks if the taxonomy term has a dash in it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joshua.roberson’s picture

I have the same problem.

Vocabulary terms:
Eagle Ford [works: /sc/eagle-ford]
Marcellus-Utica Midstream [fails, should be: /sc/marcellus-utica-midstream]

It seems like the process is to take the URL taxonomy and convert the hyphens to spaces before comparing it to the terms. This seems backwards. It should take the terms and convert the spaces to hyphens (SEO friendly URLs) and compare them to the URL taxonomy which is already SEO friendly.

I also notice that if the term name has an ampersand (&) like "Latin America & Caribbean", the URL taxonomy has to have the ampersand in it. I'm sure it is the same for other special characters.

works: /sc/latin-america-&-caribbean
shoule be: /sc/latin-america-caribbean

DamienMcKenna’s picture

@jrobertson: The URL is not expected to be customized like that, it literally only converts spaces to dashes and makes the string lowercase, it doesn't do anything else, so your URL shouldn't change that way.

I think the problem is that we're used to the magic Pathauto can do and want it for these pages too, when it doesn't have that level of functionality.

erikwebb’s picture

What if we urlencode the original hyphen prior to the hyphen/space sub, then on load, do the hyphen/space sub prior to urldecode? That should avoid this problem.

str_replace('-', '%2D', $str);

DamienMcKenna’s picture

FYI I ended up building a work-around using the Safeword module and the following patch: #2329443: CTools argument

DamienMcKenna’s picture

Erik: From experience, this doesn't really provide the flexibility that many sites need, they want something more akin to the clean URLs provided by Pathauto.

klausi’s picture

Status: Active » Needs review
FileSize
980 bytes

I think we should only transform dashes to spaces as a fallback if no terms could be loaded. Patch attached.

klausi’s picture

Rerolled.

khyam’s picture

For reference to anyone, patch works great for terms with hyphenated names. It doesn't however work for terms with a hyphenated name and a space.

Example:
practice-related : works
practice-related news : doesn't work

In our case the url had to be /practice-related%20news/ in order to make this work

joelpittet’s picture

Maybe it needs to be url decoded?

Chris Matthews’s picture

Status: Needs review » Needs work

Needs work per the comment in #8 and #9