I've setup a listing with this pattern:

store/[node:field-store-address:locality]-[node:field-store-address:administrative_area:]/[node:title]

However, some of the store types don't have the address field fully populated. In that case, I get two slashes and only need one:

http://www.mydomain.com//[node:title]

How do I have it remove the slashes if those fields are empty? So it would be:

http://www.mydomain.com/[node:title]

Thanks for your help. 3 hours into this and figured I would ask for a lifeline here.

Comments

magicmirror’s picture

Any thoughts on this? Would sure appreciate some feedback.

dave reid’s picture

Is your separator in Pathauto set to the dash character? If those two tokens produce empty output, that is strange because Pathauto should recognize that the resulting string (with leading / trailing separators trimmed) would be empty.

dave reid’s picture

Component: Bulk generation » Code
Assigned: Unassigned » dave reid
Category: support » bug

Hrm, actually looking at the code, it looks like this may not actually meet any of the code conditions to get cleaned up in Pathauto.

dave reid’s picture

Status: Active » Needs review
StatusFileSize
new904 bytes

Let's start with some tests to confirm the behavior.

Status: Needs review » Needs work

The last submitted patch, 1899806-multiple-empty-tokens-pathauto-clean-alias-tests.patch, failed testing.

magicmirror’s picture

Yes, my separator is set to the dash. Thanks for taking a look at this.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new2.9 KB

Ok, let's test this one.

dave reid’s picture

Status: Needs review » Fixed

Committed #7 to 7.x-1.x and a new 7.x-1.x-dev release will be available within 12 hours. http://drupalcode.org/project/pathauto.git/commit/88c2b14

Thanks magicmirror for reporting this edge case!

dave reid’s picture

Version: 7.x-1.x-dev » 6.x-2.x-dev
Status: Fixed » Patch (to be ported)
magicmirror’s picture

Seriously awesome! Thank you!

k_a_l’s picture

Version: 6.x-2.x-dev » 6.x-1.6

Could I apply this patch to vs 6.x-1.6?

dave reid’s picture

Version: 6.x-1.6 » 6.x-2.x-dev

You could try but it might require some adjustment. It needs to be fixed in 6.x-2.x first, then backported to 6.x-1.x last.

k_a_l’s picture

Thanks Dave. I think I'll just update the module.

kristoferaberg’s picture

magicmirror: What have you done in order to be able to use [node:field-store-address:locality] as a pattern in pathauto? I only get [node:field_address] as a suggestion, but can't choose parts of the address, like locality and throughfare (from the module Address Field).

Edit: I found the answer myself: http://drupal.org/project/addressfield_tokens :)

dave reid’s picture

Issue summary: View changes
Status: Patch (to be ported) » Needs review
StatusFileSize
new2.9 KB

Patch for 6.x-2.x.

dave reid’s picture

Status: Needs review » Fixed
dave reid’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

Status: Fixed » Closed (fixed)

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