At the moment, pathauto settings (e.g. to replace spaces with a dash) are not applied to the part of the path generated using the menutrail tokens ([menu-trail-parents-path] and [menu-trail-parents-path-raw]). That's because they are suffixed with '-path' to avoid the slashes being stripped out (see #444630: Using menutrails with pathauto: forward / being stripped due to incorrect naming of token ), which is all well and good. However, I do still want my pathauto settings to be applied so I wrote this patch. It passes each of the trail parts through pathauto_cleanstring() individually before concatenating them into the path token.

I have added a new token [menu-trail-parents-pathauto-settings-applied-path]. It's a bit of a mouthful, isn't it? I just didn't think it was a good idea to do this to [menu-trail-parents-path] in case people want to use that in some context other than pathauto. Any suggestions on token naming would be most welcome!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

auberdjinn’s picture

Status: Active » Needs review
FileSize
1.8 KB

And here's the properly named patch. I think.

Dave Reid’s picture

Status: Needs review » Needs work
Issue tags: +pathauto, +path tokens

Nope. Please see #881270-142: [bookpath], [menupath], [*path] tokens not cleaned: aliases without punctuation removed, lower casing, etc. for the proper way to provide 'path' style tokens that will still work with Pathauto.

auberdjinn’s picture

Category: feature » bug
Status: Needs work » Needs review
FileSize
932 bytes

Great, I'm glad there is now a nicer way to do this! And I'm sorry I didn't pick up on that issue before.

To summarise the linked issue, Pathauto now allows path tokens to be provided as arrays of the path parts so processing can be applied.

The attached patch simply provides the existing path tokens in the correct format if Pathauto is requesting them. No new tokens, no messy stuff.

I have also changed the category to bug report since I would say this is unexpected behaviour, and having spaces in URLs can cause problems. To reproduce:

  1. In pathauto general settings, check that "separator" value is set to '-'
  2. Set default node path pattern to include [menu-trail-parents-path-raw] and ensure this is the only node pattern
  3. Create a new node with a menu item and "automatic alias" box ticked
  4. See that the menu trail in the newly-created path contains spaces where there should be dashes

Note that this patch only fixes the issue in conjunction with Token and Pathauto dev versions (since Sep 28).

joegraduate’s picture

I just tested the patch in #3 after installing the new releases of Pathauto (6.x-1.5) and Token (6.x-1.15). The [menu-trails-parents-path-raw] token is working correctly. Thanks catfink.

Dave Reid’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

sun’s picture

Status: Reviewed & tested by the community » Fixed

Entirely trusting your review as Token co-maintainer, Dave. I.e., didn't test this patch myself.

Thanks for reporting, reviewing, and testing! Committed to HEAD and D6.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Anonymous’s picture

This works great when the node I'm auto-aliasing is actually in the menu, but it doesn't work when it's not. If I set it such that a node should appear under a specific menu item, but not actually create a new menu item, then I think the [menu-trail-parents-path-raw] should still be valid. Unfortunately this is not the case.

Example:

I have an article 'New Library Donations' filed under the vocab term 'education'. My menu is such:

- projects
- education
- healthcare
- welfare

I set menutrails such that anything filed under the taxonomy term 'education' should have project>education as the active trail. My breadcrumb shows 'home>projects>education>New Library Donations.

I then set pathauto such that any node has the [menu-trail-parents-path-raw]/[title-raw] pattern (just to ensure that it tried to use that pattern).

Unfortunately all I ever get back as the autocompleted URL is the [title-raw] part. Is there a way to fix this?

Status: Fixed » Closed (fixed)

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

chill8331’s picture

Status: Closed (fixed) » Needs review

Is there anyone noticed [menu-trail-parents-path-raw] can't convert letters that not in English?
I'm using
Pathauto 6.x-2.0-alpha3
Transliteration 6.x-3.0
Token 6.x-1.15
and even tried dev versions.

In my case, This combination is working brilliant when convert node title from Chinese to Pinyin in URL. I figured Transliteration does this.
It doesn't work when i choose [menu-trail-parents-path-raw] pattern. The menu name stays in Chinese. The URL is working. Although, It will become unreadable under IE and it's not good for SEO. Is it has anything to do with i18n module? I'm not sure how this combination works in the code exactly.

Anyhow, Is there anyone can sort it out please?
Thanks in advance!

MPeli’s picture

@chill8331
I am facing the same issue. [menu-trail-parents-path-raw] pattern contains parents title including capital letters and special characters (f.e. ěščřžýáíé) which can not be removed.

rjmackay’s picture

Status: Needs review » Closed (fixed)

@chill8331 @mpeli
I'd suggest you should open a new issue for your problem.
It may be related, but its not the same bug. This issue has been resolved and committed.

Daniel Wentsch’s picture

@sypl: it's been a while, but have you found a solution for the problem you described? I'm having the exact same issue right now and wonder how to solve it.
Why would we need menutrails token at all when nodes need to have an menu entry to appear there? The whole point for using menutrails ist _not_ having menu entries for every node.