Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Wysiwyg data importing into Grid column behaves differently vs standalone wysiwyg field

Status Resolved
Add-on / Version DataGrab 5.0.2
Severity
EE Version 7.2.11

Foster Made

May 19, 2023

Hey Brian, I found another issue while testing 5.0.2 (thanks for that btw!).  Some of the data we need to import is wysiwyg content and the client is copying and pasting data from their catalog data and pasting it into the spreadsheet, which has line-breaks in the content.  Exporting it to CSV loses the formatting as we’d expect, but the issue is that if the data is imported into a Wygwam field inside a Grid, everything after the first line-break gets stripped, whereas this doesn’t happen if the exact same column in the CSV is imported into a standalone Wygwam field.  See screenshots attached and if you need the CSV it’s at https://store.lab-aids.com/temp/kits-test-import.csv

I tried manually replacing the line-breaks in the CSV with
and that sort of helped, but then the commas in the content were causing the data to be split across multiple Grid rows.

Is it possible to fix this so the import into the Grid column Wygwam fields acts the same as the standalone Wygwam field?  Thanks!

#1

BoldMinded (Brian)

Try this change in the dt.datagrab_csv.php file, on line 263.

Change this

return trim($sub_items[$this->sub_item_ptr - 1]);

to this

return trim(stripcslashes($sub_items[$this->sub_item_ptr - 1]));
#2

Foster Made

Comment has been marked private.

#3

BoldMinded (Brian)

This doesn’t make much sense, DataGrab doesn’t care that it’s a wysiwyg field, it just sees it as a text field. Does this happen to other entries? The screenshots show a line of text followed immediately by a <ul>, what happens if it’s not html and just a line break?

#4

Foster Made

Comment has been marked private.

#5

BoldMinded (Brian)

This isn’t a Wygwam/RTE issue, it happens if importing into a Textarea field inside of Grid too. Still no clue why…

#6

BoldMinded (Brian)

There is a stripcslashes function call on line 92 of AbstractDataType.php… try removing it and see if it makes a difference. Change it to

return trim($items[$id]);
#7

BoldMinded (Brian)

Disregard that last comment. So, I’m not sure how, or if I can fix this, without really breaking other things in DataGrab and other people’s imports. What’s happening is that it’s making assumptions, at least for the Grid field, that new lines indicate a sub item in the Grid row, e.g. data for an Assets field, a Relationship assignment etc. At least in the CSV import code. Are you able to convert this import to another data type? JSON or XML maybe?

#8

BoldMinded (Brian)

I might have a solution for importing it into a Grid field, but I still need to fix the stripping of new lines when it’s inserted into an RTE field. It works fine if it’s just a basic textarea field.

The solution is to wrap the text in a <![CDATA[ … content here … ]]> tag so it knows not to split up the lines as separate sub items.

I’ll share a new build when I can get the RTE field issue sorted out.

#9

BoldMinded (Brian)

Next comment will have link to a build that should stop the truncation of the text, if you wrap it in the CDATA tag mentioned above.

As for the formatting, I can’t do anything about that. RTE/CKeditor expects to contain actual html tags, and it would be a lot of work for me to parse text and try to wrap everything in p tags, and in your example you have bulleted text, so that means wrapping it in li tags. I think you’ll need to update your import file to have pre-formatted HTML in those columns where you’re importing into an RTE field.

#10

BoldMinded (Brian)

Comment has been marked private.

#11

Foster Made

Sorry for the delay, this account is shared and for whatever reason I’m not getting replies to my own address despite ‘subscribing’ with my personal address. But thanks for following up with this and I’ll test. Losing the formatting is fine - we expected that. And wrapping with <![CDATA[ … content here … ]]> should be doable too. I’ll test and let you know!

#12

Foster Made

Comment has been marked private.

#13

BoldMinded (Brian)

I can’t automate that with DataGrab. The whole reason for adding it is b/c DG doesn’t know that the column value that has multiple lines should be considered 1 blob of text, otherwise it assumes they’re sub items (related data) to import. That’s why I added the detection of the CDATA tag. If it sees that it doesn’t try to look for sub items and takes the blob as the field value.

#14

Foster Made

Comment has been marked private.

#15

BoldMinded (Brian)

Comment has been marked private.

#16

Foster Made

Comment has been marked private.

Login to reply