I have some categories that have (), - and / in their titles.
In the 5.x-2.x branch brackets are displayed as %28 and %29 and the slash is just displayed as it is - /.
Also, the hyphen (-) is for some reason displayed as %E2%80%93.

The 5.x-1.x replaced all those characters with the separator.

CommentFileSizeAuthor
#4 pathauto_term_slash.patch856 bytesgreggles

Comments

greggles’s picture

If you create the url aliases manually do they show the correct values? I.e. go to http://example.com/admin/build/path/add and add the alias wit the right characters in it.

Also, did this problem show up after applying http://drupal.org/node/148804 ? If so then it's related to that and should be discussed inside of that issue.

wallebart’s picture

I read your post but I think there is a separate issue with terms with '/' in its title.

In that case Pathauto builds the path formal correct - the titles are 'imploded' as they are, separated with '/' - but not logical. The '/' in the title opens a new hierarchical level, which is mostly not intended.

Example:

- books/magazines
-- daily
- books
-- crime

gets

- books/magazines
- books/magazines/daily
- books
- books/crime

It seems that books/crime is the same path level as books/magazines but it isn't so.

To solve that (quickly) for me I patched pathauto_token_values() in pathauto.module as follows :

      //...
      $separator = variable_get('pathauto_separator', '-');
      $parents = taxonomy_get_parents($category->tid);
      // slashes in term name should be replaced by separator
      $catpath = preg_replace("§/§", $separator, $category->name);
      foreach ($parents as $parent) {
        // slashes in term name should be replaced by separator
        $catpath = preg_replace("§/§", $separator, $parent->name) .'/'. $catpath;
      }
      //...

Maybe it will help to solve the issue.

p.s. Possibly [menupath] from Token generates the same wrong result.

greggles’s picture

Title: Pathauto doesn't correctly handele brackets, slashes and hypens in node and category titles » Pathauto should "clean" tokens one by one to properly handle slashes

I'm changing the title - I generally agree with henry polte's solution, though not exactly with the implementation. As you point out we'll want to do this more generally since it will affect menupath as well.

There's also a larger issue of what to do with tokens that return multiple values (like catpath, menupath, etc.) which needs to be deal with prior to finding a real solution...

greggles’s picture

Assigned: Unassigned » greggles
Status: Active » Needs review
StatusFileSize
new856 bytes

Actually, I'm now thinking that henry polte's solution is perfect. Attached patch does basically the same thing. The major changes were:

1. consistent preg_replace pattern style
2. standardized comment (capitalized first letter)
3. Replacing with separator rather than just dropping the characters

@henry polte - it would be great if you could provide patches in the typical patch format to expedite testing/reviewing.

greggles’s picture

Title: Pathauto should "clean" tokens one by one to properly handle slashes » remove slash from catpath as it gets built to prevent weird urls
Status: Needs review » Fixed

Committed to the 5.x-2.x branch. Thanks, henry polte!

Anonymous’s picture

Status: Fixed » Closed (fixed)
czeky’s picture

Unfortunatelly getting "vocabulary-term-subterm" when creating cathegories, even with the latest release of pathauto instead of "vocabulary/term/subterm", any chance to find help?

Many thanx

czeky

greggles’s picture

Status: Closed (fixed) » Active

The right status helps to begin ;)

Other than that if you can debug the building of the catpath token in the pathauto.module's pathauto_token_values that's the problem area.

Thanks.

greggles’s picture

Status: Active » Fixed

czeky - I think your problem is probably actually http://drupal.org/node/168321 - do you have transliteration enabled? If so, it's based on that problem...

Anonymous’s picture

Status: Fixed » Closed (fixed)