Closed (fixed)
Project:
Address Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
21 Mar 2012 at 17:42 UTC
Updated:
12 Dec 2015 at 14:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
snufkin commentedI think this is a formatter issue. When I set my addressfield to be formatted as address form (as format handler) I get the entries just in one line, concatenated. If i set the formatter to anything else the field will not be included in the export. Maybe its an issue with data export only accepting one line output, or doing the concatenation itself?
Comment #2
caschbre commentedNot sure if this is related, but an addressfield cannot be exported / imported with the Features module either. I can provide more details if it sounds related.
Comment #3
bdragon commentedHere's a low impact change that adds some newlines to the output. This seems to do the trick when doing csv exports and such, and shouldn't impact the normal theming since html ignores newlines.
Comment #4
bdragon commentedWhoops, forgot to strip paths on that patch. Rerolling against an actual checkout....
Comment #5
rszrama commentedThere seem to be a few issues being reported here. I installed Views Data Export and was able to:
Either something changed in this module or in Views Data Export to prevent the various bugs reported above. The point above about the Features module does not apply to this particular discussion, but if you can reproduce the inability to export an Address Field and track it down to a problem in this module, I'd be interested to know how that's even possible given our dependence on the same Field API hooks as any other field.
That said, my CSVs do have the address concatenated on a single line as noticed by snufkin, and as bdragon pointed out, that's because the markup generated for the rendered field does not have any line breaks. It's harmless to add them in, but in testing the patch I noticed the unfortunate side effect as it pertains to data export that if you just do something simple like only use the name line plugin, then you end up with a line break after the name even though there are no additional lines.
I've attached my update to bdragon's patch, but I'm not going to commit it just yet. I feel like it might be better to handle this earlier using suffixes in the render array where we can process it to only put them in if necessary.
Comment #6
farmherd commentedDoes this need to be accomplished within the module itself or would it sit better with a theme function?
I note that addressfieldtokens module includes formatters for exporting an address to one line for use with exports using a comma;
A quick test replacing line 82 of the function theme_addressfield_formatter__linear within addressfield_tokens.theme.inc [ $output = implode(', ', $out) ; ] with $output = implode("\n ", $out) appears to give the functionality desired above. (note the double quotes)
Duplicating and renaming that function with addressfieldtokens would seem to be an appropriate way forward rather than putting the functionality directly into addressfield
This approach also avoids the problem of the superfluous newline created when a field is blank.
Comment #7
dang42 commentedAny further progress on this?
For my use case, it would be fine to either (a) separate each field into its own column (when exported), or (b) concatenate all the address fields into one column.
Applying the patch in #5 did separate the street address and city fields (though it pushes the city to a 2nd line for some reason...), but it did not separate the state & zip code fields.
ETA:
Nevermind...
I had been trying to export the full "Address" field - removing that & exporting the individual fields (Address - City, Address - State, etc.) works exactly as expected.
Comment #8
catchJust ran into this and considered the same as #5, then found this issue when searching. I think that patch is actually fine - it's not going to have negative side-effects and making this configurable seems unnecessary.
Comment #9
rooby commentedI've run into this too.
Ideally the views field handler would have a field where you can enter a separator, then you could have " " or ", " or "\n" or whatever suited your requirements.
Comment #10
rooby commentedThe current patch is working for me though.
Comment #11
tonylegrone commentedIs there any possibility of rendering each component as a separate field instead of a single field with the whole address? This would give each component it's own column in the data export and potentially making a more usable export in the end.
Comment #12
tonylegrone commentedRerolled #5 to match latest code.
Comment #13
dtamajon commentedPatch is working fine to me on export and no side-effects on display.
Comment #14
dtamajon commentedJust a small adjust... PHP_EOL should be used instead "\n", to help newline handling based on platform.
Comment #15
leewillis77 commentedThis is a re-roll of the patch in #12 with the modification to change \n to PHP_EOL as suggested in #14.
Works well for us here.
Comment #16
liquidcms commentedthis worked for me; great help.. thanks.
Comment #17
anybodyWorks great for me! Further feedback to get this RTBC? :)
Comment #18
leewillis77 commentedI think there are four separate people happy with this patch & approach. RTBC?
Comment #19
bojanz commentedCommitted.