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

jenlampton’s picture

Issue summary: View changes

add examples of what I mean

amarcus’s picture

Look at addressfield_tokens. :-)

amarcus’s picture

Issue summary: View changes

hyhenate

rszrama’s picture

Title: support for multiple display formatters » Add a "Custom address format" display formatter supporting custom token patterns
Issue summary: View changes

There'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. : )

jhedstrom’s picture

Seems 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.

rszrama’s picture

That's already been done; see addressfield.tokens.inc in -dev.

jhedstrom’s picture

Re #4: while the module now defines tokens, it doesn't provide a field formatter that uses them, unless I am missing something?

rszrama’s picture

Gotcha. 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.

philsward’s picture

Is 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.

timodwhit’s picture

This 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

EdPhillis’s picture

#8

Tim, you, sir, are a gentleman, a scholar and an acrobat. Thanks!