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
Comment #1
magicmirror commentedAny thoughts on this? Would sure appreciate some feedback.
Comment #2
dave reidIs 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.
Comment #3
dave reidHrm, actually looking at the code, it looks like this may not actually meet any of the code conditions to get cleaned up in Pathauto.
Comment #4
dave reidLet's start with some tests to confirm the behavior.
Comment #6
magicmirror commentedYes, my separator is set to the dash. Thanks for taking a look at this.
Comment #7
dave reidOk, let's test this one.
Comment #8
dave reidCommitted #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!
Comment #9
dave reidComment #10
magicmirror commentedSeriously awesome! Thank you!
Comment #11
k_a_l commentedCould I apply this patch to vs 6.x-1.6?
Comment #12
dave reidYou 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.
Comment #13
k_a_l commentedThanks Dave. I think I'll just update the module.
Comment #14
kristoferaberg commentedmagicmirror: 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 :)
Comment #15
dave reidPatch for 6.x-2.x.
Comment #16
dave reidCommitted #15 to 6.x-2.x. http://drupalcode.org/project/pathauto.git/commit/3d9ca28
Comment #17
dave reid