Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There is an issue I found over at the Views Data Export module forums that I believe may be an Addressfield issue: the inability for Addressfield information to be successfully exported within an otherwise successful Views export. The issue is here: http://drupal.org/node/1437022
Comment | File | Size | Author |
---|---|---|---|
#15 | 1493014-15.container_line_breaks.patch | 804 bytes | leewillis77 |
#12 | 1493014-12.container_line_breaks.patch | 801 bytes | tonylegrone |
#5 | 1493014-5.container_line_breaks.patch | 937 bytes | rszrama |
#4 | addressfield-newlines-2.patch | 574 bytes | bdragon |
#3 | addressfield-newlines.patch | 814 bytes | bdragon |
Comments
Comment #1
snufkin CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: bdragon commentedWhoops, forgot to strip paths on that patch. Rerolling against an actual checkout....
Comment #5
rszrama CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: 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 CreditAttribution: rooby commentedThe current patch is working for me though.
Comment #11
tonylegrone CreditAttribution: 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 CreditAttribution: tonylegrone commentedRerolled #5 to match latest code.
Comment #13
dtamajon CreditAttribution: dtamajon commentedPatch is working fine to me on export and no side-effects on display.
Comment #14
dtamajon CreditAttribution: dtamajon commentedJust a small adjust... PHP_EOL should be used instead "\n", to help newline handling based on platform.
Comment #15
leewillis77 CreditAttribution: 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 CreditAttribution: liquidcms as a volunteer commentedthis worked for me; great help.. thanks.
Comment #17
AnybodyWorks great for me! Further feedback to get this RTBC? :)
Comment #18
leewillis77 CreditAttribution: leewillis77 at Upbeat Productions commentedI think there are four separate people happy with this patch & approach. RTBC?
Comment #19
bojanz CreditAttribution: bojanz at Centarro commentedCommitted.