Hi,

this is kind of a small feature request :-D

Is it possible to get only city as a token and field renderer, instead of City, State?!

Best regards,

Tobi

Comments

amarcus’s picture

The city is already available as a token (called "Locality" by default, unless you change it).

However, what is your specific use case for a city-only field renderer? We have found that within templates it is fairly easy to display a single component from the render array; the harder part was consistently rendering multiple components separated by commas so those were the ones we built field renderers for. Within views, I believe the addressfield module already provides view field handlers for each component of the address, so no need to use a field formatter there.

In the generic case, we could build a field renderer for every component of an address. But this may be cumbersome to actually use... But I welcome your thoughts on the matter.

--
Andrew

DerTobi75’s picture

Ah, ok, I can use the token for rewrites in my View!

My problem with the addressfield renders in the node display, I need a complete address, but only want to display the city, when a user views the node or a view.

amarcus’s picture

Assigned: Unassigned » amarcus
Status: Active » Needs review

Tobi,

I just added a new field formatter that allows you to select which components you wish to render, along with a separator to use between the components. I believe that this should handle your specific case, as well as some of the more generic cases requested in the addressfield issues queue.

Try it out!
--
Andrew

DerTobi75’s picture

Hi Andrew,

thanks for the new field formatter, it works for me! Sorry for the delay.

Best regards,

Tobi

amarcus’s picture

Status: Needs review » Fixed
j4’s picture

Hi,

Sorry to open this again, but i need a comma only after city, while I want spaces after thoroughfare, premise, and in between State and Zip Code. Is this at all possible?

Thanks!
Jaya

P.S in case someone comes here looking for the same thing..i used spaces as the separator and used for adding the comma..
span.locality:after {
content: ",";
}
Dont know if this is right! this just worked for me.

Status: Fixed » Closed (fixed)

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