Download & Extend

Empty Fields Break my URL Structure

Project:Pathauto
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:major
Assigned:Dave Reid
Status:patch (to be ported)

Issue Summary

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

#1

Any thoughts on this? Would sure appreciate some feedback.

#2

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.

#3

Component:Bulk generation» Code
Category:support request» bug report
Assigned to:Anonymous» Dave Reid

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.

#4

Status:active» needs review

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

AttachmentSizeStatusTest resultOperations
1899806-multiple-empty-tokens-pathauto-clean-alias-tests.patch904 bytesIdleFAILED: [[SimpleTest]]: [MySQL] 319 pass(es), 2 fail(s), and 0 exception(s).View details | Re-test

#5

Status:needs review» needs work

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

#6

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

#7

Status:needs work» needs review

Ok, let's test this one.

AttachmentSizeStatusTest resultOperations
1899806-multiple-empty-tokens-pathauto-clean-alias.patch2.9 KBIdlePASSED: [[SimpleTest]]: [MySQL] 322 pass(es).View details | Re-test

#8

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!

#9

Version:7.x-1.x-dev» 6.x-2.x-dev
Status:fixed» patch (to be ported)

#10

Seriously awesome! Thank you!

#11

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

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

#12

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.

#13

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

#14

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 :)

nobody click here