CMS: Import HTML to Rich Content (Insert HTML Code)

Question:
How do I import HTML into CMS with Rich Content Field?

Product:
Wix Editor > CMS

I have a Database with a Rich Content Field where I imbed HTML
Manually, there is no problem, but I want to import data into my database and cannot figure out how to “imbed” the HTML

I exported my data to see what is generated, and this is what it came out as:

The actual thing I wanted to do display the image from the url, WITHOUT uploading to media, but could not find another way to do it.

TIA.
Meirav

Why not just save the image location (from your sample: https://m.media-amazon.com/images/I/71ACK3Q4L5L._SL1500_.jpg) as a link (or text) in your database? Then when you load your page you can use a basic function to set the image src.

Example:

$w.onReady(function () { loadPage(); })

async function loadPage() {
  await $w("#yourDataset").onReadyAsync(); 
  let item = $w("#yourDataset").getCurrentItem();
  $w("#yourImage").src = item.yourURLorTextField; //https://m.media-amazon.com/images/I/71ACK3Q4L5L._SL1500_.jpg
}

This would probably be a much simpler workaround than what you are trying to do, and it should achieve the same result. Hope that helps

Thank you for replying!
I have not yet mastered the code part of wix, but will try your code…

Hopefully it will work with the repeater :slight_smile:

Will update when I have results

I have this same question, and I don’t think the solution above answers the OP’s question. I want to import rich text into the CMS and preserve formatting or html links. I tried markdown and html markup in my text and neither works. I have to go into the WIX editor and redo my formatting in the UI. What can I use that will be kept by the CSV import feature to my CMS rich text field?

Can’t believe I actually got this working!.

This took hours to get this working. Very long and circle of pain with ChatGPT to create this and my head hurts from it. But I finally got it to work. - Note I am not going to support this if it does not work for you but I did test it on some very complex html which included a lot of JS also…

This will (should) convert html to Wix style CSV for importing into a CMS.
The html will be loaded into HTML code inside a Html Component .

Before you use, you will need to create your Rich Content field in the CMS.

Or more easily, just start with a blank CMS by just creating a new one form your first import from the convertor. If you do this you must change the HTML Code field mapping from Rich Text to Rich Content. in the Import dialogue.

Once your CMS is set up either way via the above. You can then just import new CSVs

CMS item Rich Content result example from import to CMS.


Here is the Convertor.

Thank you for the script @Mark_Hunte . Also for pointing out the difference between Rich Content instead of Rich Text that I was trying to use.

Thanks @Mark_Hunte for your code above. I wanted to import news items from another website which allowed these to be exported in a CSV file. I wanted to process this file using spreadsheet functions so it became compatible with Wix.
The steps were as follows:
(The functions are from LibreOffice Calc but assume Excel ones are similar)

  1. Use the clean() function to remove non-printing characters, such as line-feeds, from your HTML.
  2. Use the substitute function to escape quotes (plain ASCII 34 quotes, not 66/99s) embedded in your HTML. You need to replace " with \".
  3. Bracket the result with the Wix Rich Text code

The whole function looks like this:

=$'Rich Content Wrapper'.$A$2&SUBSTITUTE(CLEAN($ImportedHTML.X2),CHAR(34),"\"&CHAR(34))&$'Rich Content Wrapper'.$A$5

$‘Rich Content Wrapper’.$A$2 and $‘Rich Content Wrapper’.$A$5 contain the Wix code
$ImportedHTML.X2 contains the HTML to be imported.

The Wix wrappers are

{"nodes":[{"type":"PARAGRAPH","id":"mcus4131","nodes":[],"paragraphData":{}},{"type":"HTML","id":"e9u5q130","nodes":[],"htmlData":{"containerData":{"textWrap":true,"height":{"custom":"550"},"spoiler":{},"alignment":"CENTER","width":{"custom":"940"}},"html":"<div style=\"font-family:Arial, Helvetica, sans-serif;\">

and

</div>"}}],"metadata":{"version":1},"documentStyle":{}}

These are slightly different from Mark’s in that I have changed the width and height values and have added an HTML div. I needed this since otherwise Wix rendered my HTML using a serif font while the rest of the site was sans serif.

1 Like