feed-me
feed-me copied to clipboard
Formatting is lost when updating Redactor field with FeedMe
When i try to update a Redactor field (a Commerce product description field), the content is updated, but when i output its content they appear without formatting. I have to open the product page, save it, refresh the product page, and then it works. The formatting is visible in the cp before resaving, but it just need a resave to take effect. I used the raw filter and without it, but with the same problem. I am not sure if i should post this issue here, or in FeedMe.
Craft: 3.1.34 Commerce: 2.1.8 Redactor: 2.3.3.2 FeedMe: ^4.1
Also having what appears to be this issue. The formatting is shown within the field but doesn't "work" on the front end, even when using the |raw
filter. The HTML tags just aren't rendered at all.
I've found that simply re-saving the entry doesn't help. Instead I have to actually edit the redactor field and then save the entry. When I do that the HTML formatting returns on the front end.
Craft: 3.4.15 FeedMe: 4.2.2 Redactor: 2.6.1
Having the same issue myself. One front-end of the site none of the formatting shows up after import. I have to go into the editor (where the formatting displays as expected) and manually add some newlines to the redactor field and resave. That preserves the formatting. Just saving without editing the field does nothing.
I just came across this same problem but found that if you wrap your html with a CDATA section, it will import into a redactor field as expected (I've only tested this with an XML import):
<projects>
<project>
<title>Project #1</title>
<project_content><![CDATA[<p>Some html</p><p>All the <i>formatting</i></p>]]></project_content>
</project>
...
</projects>
This problem is still persisting.
Craft: 3.5.8 FeedMe: 4.2.3 Redactor: 2.7.4
Our content has the CDATA tag wrapped around it and it still is failing to import correctly. As previous users have stated the formatting shows correctly within the field, but not on the front end when rendered.
The field in the database where the actual content is being stored does not have the html formatting in it. After making a minor edit to the content in the CP and saving, the database field is updated with all the correct html formatting.
Haven't been able to find a work around other than to edit and save each and every field.
I'm getting this issue. If you look in the code view of the Redactor field you can see the <p>
tags are there but they're not rendered on the frontend:
Rendered:
You have to modify the formatting or add a new line in Redactor field and save to get it to render correctly.
Craft CMS 3.5.12.1 Feed Me 4.2.4 Redactor 2.8.1
Also experiencing this issue.
Craft Pro 3.6.7 Feedme 4.3.5.1 Redactor 2.8.5
Anybody figure this out? Am also getting this issue
Run into the same issue as well - manually adding a line and saving the entry again resolves the issue but that's a pain with alot of imported entries.
Just encountered this issue again. On a previous project, I parsed all HTML content heavily with a node script before importing. Don't have so much time on my current project so my workaround is on the template side using nl2br
and craft's purify
filter.
Incase it's helpful:
{%- if '<p>' in entry.redactor|raw -%}
{{entry.redactor}}
{%- else -%}
<p>{{entry.redactor|nl2br|purify}}</p>
{%- endif -%}
Still have this issue Craft 3.7.17.2 with Redactor 2.8.8. @tomkiss thanks for the work around. That worked in many cases but presented some issues in other cases.
If you copy the source from the redactor field, paste and resave it solves the issue.
I am also still having this issue. Would be great if a fix was released for this!
Also still getting this issue
Still an issue.
Yes, still an issue.
Still an issue under "craftcms/cms": "4.3.4"
+ "craftcms/feed-me": "5.0.4"
...
We're getting this issue after a large FeedMe import too. Again, like others, a change to the content fixes the issue, but we've got just over 1000 entries, and that would take some time.
First off, I'm sorry because I don't have great news.
This issue occurs when the import data has something like \n
instead of actual HTML. When that happens, the data is imported and stored in the database as is (with the \n
value). When that value renders within the control panel, Redactor is initialized and will convert it to use <p>
tags via JS. From there, when the entry is updated, the new value (with <p>
tags) is sent to Craft and saved.
Redactor does all this in JS, which means we can't transform the values in the same way when parsing a field during an import because we don't have a JS runtime there.
I'm a little hesitant to implement some opinionated transformation around this because everyone's use case (and data) is a little different, and it feels like a bit of a Sisyphean task to try to handle them all.
That being said, there is an EVENT_AFTER_PARSE_FIELD
event that will let you transform the parsed value before it is set when the feed is processing.
use craft\feedme\events\FieldEvent;
use craft\feedme\services\Fields;
Event::on(
Fields::class,
Fields::EVENT_AFTER_PARSE_FIELD,
function (FieldEvent $event) {
if ($event->fieldHandle === 'yourFieldHandle') {
$initialValue = $event->parsedValue;
// Mess with the value as needed and set it to `$newValue`
$event->parsedValue = $newValue;
}
}
);
This event (and its EVENT_BEFORE_PARSE_FIELD
sibling) are currently missing from the docs, so I've opened #1215 to add them to the docs.
I'm going to close this issue for the moment, but happy to keep the conversation going if someone has a good way to solve this that I'm not considering.
It's a shame there isn't a server-side / PHP version of the Redactor parser to solve this with.