In some places I'd like to display a complete address including country, but in other places Id like to hide the country, and in still others I'd like to show only the city and state.
It would be great if the display formatter would provide an option that let me choose which pieces of the address to display, as well as allowing me to establish "presets" for address.
Full-address
East Bay
2619 Broadway
Oakland California 94612
United States
no-country
East Bay
2619 Broadway
Oakland California 94612
city-state
Oakland, California
and then in the drop-down for formatter, I could see tese three options.
Comments
Comment #0.0
jenlamptonadd examples of what I mean
Comment #1
amarcus CreditAttribution: amarcus commentedLook at addressfield_tokens. :-)
Comment #1.0
amarcus CreditAttribution: amarcus commentedhyhenate
Comment #2
rszrama CreditAttribution: rszrama commentedThere's nothing preventing us from adding additional display formatters, but instead of trying to add individual formatters for each potential configuration, why don't we just add a display formatter that lets you define a token pattern to use? This is actually possible now that we have tokens in this module. : )
Comment #3
jhedstromSeems to make sense to pull in some, or all, of the addressfield_tokens module, or link that project from the project page so folks can find it more readily.
Comment #4
rszrama CreditAttribution: rszrama commentedThat's already been done; see addressfield.tokens.inc in -dev.
Comment #5
jhedstromRe #4: while the module now defines tokens, it doesn't provide a field formatter that uses them, unless I am missing something?
Comment #6
rszrama CreditAttribution: rszrama commentedGotcha. I read your comment but missed the part about wanting to do that specifically to add display formatters. If I'm not mistaken, I implemented the tokens differently, and recommending that module would result in people having three sets of tokens to use for Address Field (assuming they're using Entity Tokens b/c of Rules or some other module). I'd as soon leave the link out and get what's necessary into this module.
Comment #7
philsward CreditAttribution: philsward commentedIs this a good place to ask if there is any future for adding the full state as a token as opposed to just the abbreviation?
I have a view where I want to group addresses by state and I've added Address - Administrative area (i.e. State / Province) but it only outputs the abbreviation... I think the default of the abbreviation is fine, but maybe adding an additional token for the full state name would be nice for rewriting the field.
Comment #8
timodwhit CreditAttribution: timodwhit commentedThis isn't exactly what is being looked for but I went down the route of tokens and had some issue with the possibility of recursion, and narrowing the field down to only the addressfield. However to combat that, I wrote a small field formatter module for addressfield that is pretty straightforward to use and addresses some of the use cases above without duplication of tokens.
https://www.drupal.org/sandbox/timodwhit/2510284
Comment #9
EdPhillis CreditAttribution: EdPhillis commented#8
Tim, you, sir, are a gentleman, a scholar and an acrobat. Thanks!