Dev 2011-Jul-01 (1309567725)

Why is all HTML removed from export and no specific settings to change this? This module isn't as effective if we can't retrieve raw data. Same goes for extra spaces and returns.

Files: 
CommentFileSizeAuthor
#34 views_data_export-1224894-keep-html-option-with-tests.patch5.36 KBSteven Jones
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1224894-keep-html-option-with-tests.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#22 views_data_export-1224894-22-D6.patch1.86 KBCottser
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#10 html_in_csv-1224894-10.patch1.87 KBidflood
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch html_in_csv-1224894-10.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

seems like CSV is only effected?

Title:Text HTMLAdd an option to not strip tags from CSV export
Version:6.x-2.x-dev» 7.x-3.x-dev
Component:User interface» Code
Category:bug» feature

Subscribe

Also need a way to get full HTML exported via a csv option.

While it would be nice to have this as an interface option - you can achieve this by editing a file to remove the php strip_tags() function:

edit line 480 of this file views_data_export/theme/views_data_export.theme.inc

change $output = decode_entities(strip_tags($value));
to      $output = decode_entities($value);

Now your CSV rows will be output with HTML.

That's the line number as of my post in 7.x-3.x-dev, however if line numbers change within the file just look for this section of code to change the strip_entities bit in the rows only:

  // Format row values.
  foreach ($vars['themed_rows'] as $i => $values) {
    foreach ($values as $j => $value) {
      $output = decode_entities(strip_tags($value));
      if (!empty($vars['options']['trim'])) {
        $output = trim($output);
      }

Status:Active» Closed (works as designed)

#5 is evil - don't hack module!

There are already multiple preprocess theme functions available, either implement the hook in your custom module or theme.

template_preprocess_views_data_export_csv_header()
template_preprocess_views_data_export_csv_body()
- OR -
template_preprocess_views_data_export_csv()

ckng, I can't speak for the other users here, but for myself - I don't know how to create modules or template_preprocess functions. I did the only thing I knew how to do - change some basic php. I'm just learning the "Drupal Way" and it would have never occurred to me that the correct way to accomplish this would be a) creating a separate module to modify this module, or b) creating some function in the theme layer... what if I change my theme? I just want some CSV output.

If you would kindly show us the proper way to have added this functionality somehow with a copy/paste code example and instructions, please do. If not then I'll have to stick with my evil hacked module.

Thanks,
-- Tony

Status:Closed (works as designed)» Active

Sorry to reopen this issue, but I feel it can be a common task. The clean solution right now it to copy these two "long" 60 lines functions to only change 2 lines, or did I miss something?

So if I can come up with a patch that adds an option to the csv export to keep html tag has it any chance to be accepted?

Patches would be most welcome, and I'd like to get this feature in.

Status:Active» Needs review
StatusFileSize
new1.87 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch html_in_csv-1224894-10.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Here is a quick patch that fixed my specific issue. It simply adds a 'Keep HTML tags.' option to the csv export style.

Status:Needs review» Reviewed & tested by the community

An initial scan of the patch looks good to me.

comment to #5: It's not recommended to hack source code. Please remove #5 or mark it as not recommended. (@brentratliff & drupleg: sorry for the previous harsh post, I appreciate a lot that you spend the time to investigate on this issue, thank you.)

Steven Jones: Patch from #10 worked for me on D7.12 and Views 7.x-3.1.

I'd love it to see this being commited to upcoming Views Data Export releases.

Greetings

idflood - thank you for the patch, it worked well for me, and helped me learn something useful.

Maxelli, last I checked the saying was "don't hack Core", the whole point of source code is to explore and hack it. This module is not Drupal Core, and it's not something I am contributing back to the community, it's a -dev version on my dev site to do whatever I want with - my evil hack worked very well for my specific use case, and I thought it was worth sharing with the others on this post (which had gone 7 months without any other suggestion about how to get full HTML out of this module). Feel free to remove my previous post, and pardon me for trying to help in the only way I knew how.

I don't see any reason to remove the post, that's a little extreme. Sometimes hacking a module is prudent, you just have to manage the patches yourself in the event of an upgrade. Pressflow hacks core and it powers most of the high performance sites including this one. In this case, there's certainly a more Drupal way to do it and a hack is not required, but this is open source and the dialog is how we learn. @drupleg is trying to help and being shafted for it. As a module maintainer, I appreciate any code contributions as they may lead to an eventual solution.

Alrighty, we're all friends again! :) If idflood's patch looks good to Steven he'll roll it in to the module and close this issue. Thanks everyone!

Another confirmation here. Looks good and ready to get this into a release.

Could you please tell me if this is already commited? Can't see it in the release notes of 7.x-3.0-beta6. Thanks!

#10 works for me. I'm a little curious why keeping HTML tags isn't the default behavior (with possibly an option to strip), since tags can be removed from each field by views.

Make sure formatter isn't a link in output fields or #10 lets the output fields contain html tags... which isn't wanted in cvs. Also, an image field will contain ... tags, this lets feeds import fail, uncheck "show as link" selection and strip html tags in rewrite results so you are left with only the link to the file.

Download of <a%20href="http://www.sitename.com/sites/default/files/image.jpg"%20target="_blank"><a%20href="/content/url-path">http://www.sitename.com/sites/default/files/image.jpg</a></a> failed with code -1002

Patch applies cleanly, works as described, and I was able to use Views to strip some of the tags as well. Still RTBC, thanks @idflood!

Does anyone know what to do with 6.x version? Is this maybe commited in -dev versions?

StatusFileSize
new1.86 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Here's a patch against 6.x-2.x-dev that applies to 6.x-2.0-beta6 as well.

Confirm #10 works and I would argue that this is a great pretty critical addition to the module.

#22 works for D6, thank you Cottser!

Status:Reviewed & tested by the community» Needs work
Issue tags:+Needs tests

We're adding tests to the module, so this patch will also need some tests to get in. Sorry!

Status:Needs work» Needs review

#10: html_in_csv-1224894-10.patch queued for re-testing.

Status:Needs review» Needs work

Back to 'Needs work' for those tests.

Sorry :)

Status:Needs work» Reviewed & tested by the community

I use:
D7.16
Views 7.x-3.5+20-dev (2012-Oct-25)
Views data export 7.x-3.0-beta6+22-dev (2012-Oct-28)

I have tested patch at #10 to export an csv file.

It works very fine, if I want and I can drop this featcher, if I like. Famous!!!

Please import this patch very soon! Thank you very much.

Wusel

Status:Reviewed & tested by the community» Needs work

Back to needs work since we need to add tests.

@idflood:
I think, if the user does not check the new option, then there is no difference than without this D7-patch.

So I can not understand, why this patch shall not be imported to the dev-version. Sorry!

The age of this issue is more than ONE year. The age of #10-patch is several month old and there are very many good comments and no test-data, which fails the test, which we can test.

I hope, you change you opinion.

Wusel

@ wusel
I disagree. We need tests for this one. Maybe at the moment it works, but in upcoming new features and refactoring there could be overseen changes which could cause problems with this feature when we do not add tests.

@hauptm:
I disagree! If the user does not check the new option, then there is no difference than without this D7-patch.

So I can not understand, why this patch shall not be imported to the dev-version soon. Sorry!
Then everybody can test and we get a better module.

Status:Needs work» Needs review
StatusFileSize
new5.36 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch views_data_export-1224894-keep-html-option-with-tests.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Here's the patch from #10, with some tests.

Version:7.x-3.x-dev» 6.x-2.x-dev
Status:Needs review» Patch (to be ported)

Sweet, thanks everyone. This just needs to be backported to 6.x-2.x.

Sorry, if that wasn't clear, I've pushed the patch into 7.x-3.x and added tests.

Greate job - also you could apply it to the 6th version of the module. Thanks a lot! I`ve patched my 6th version and`ve been able to migrate a lot of nodes with tags)

@rootical - if you can post a patch for 6.x-2.x that would definitely help move this along :)

Status:Patch (to be ported)» Needs review
Issue tags:-Needs tests

Status:Needs review» Needs work
Issue tags:+Needs tests

The last submitted patch, views_data_export-1224894-keep-html-option-with-tests.patch, failed testing.

Status:Needs work» Patch (to be ported)

Patch from #34 needs to be backported to Drupal 6.

Here's the documentation on backporting core patches: http://drupal.org/node/1538380

Status:Patch (to be ported)» Needs review

#10: html_in_csv-1224894-10.patch queued for re-testing.

Turns out this XLS export approach is a dead end. You'll find that <a> tags at the very least get stripped.

But at least there's always sql queries if you make a dump of the database.

To do that you can export a copy of the db, upload it somewhere safe and run queries against it. If you copy past the query from your dat export view you'll get results that can be exported as a .csv

Body content is found in the node > revisions table. You don't need to know that, but seeing it there is a good small step to explore how the db is structured and give you more of a whole picture of how drupal does what it does.

Version:6.x-2.x-dev» 7.x-3.x-dev

#36 worked for me, but in my case it was not enough.
I use markdown filter, so body field stored in database differs from body field rendered to html.
I needed to export original value (which is stored in database column`field_revision_body`.`body_value`). Even though current dev version of Views data export enables html tags, it collects values after text filters applied on them.
This sandbox raw formatter project enables unfiltered output of a field in views, so value can be exported unaltered as it stored in database.
FYI.

#22 works with me Drupal6 ... Thank you Cottser ..

Any chance we could have this option for text files as well. I need to dump the contents of a single field out to a text file and I don't want the HTML stripped

Thanks
Chris

Issue summary:View changes

Why this patch is not in the dev version of this module?

Notice. When using drush to generate file via command:

drush views-data-export view-name view-id file.csv

It won't generate any file because of HTML :(

#5 worked for me in d6. I am going to use like that on a temporary basis to get my content out of an old site.