Link HMTL block to a CMS

Question:
Is it possible to link a custom html block with a CMS entry?

Product:
Wix Studio

What are you trying to achieve:
I have dynamic pages each with an interactive calculator. I would like to add all the code in a CMS entry:
Calculator #1: Name (Title) and Code (Rich Text)
Calculator #2: Name (Title) and Code (Rich Text)

Then display the calculator on the live site.

What have you already tried:
I don’t see a way to link the CMS to the custom HTML block. I asked Claude Sonnet. And the HTML works as is, without linking. But I don’t see a way to link.

You can’t link it, you will have to do a bit of coding. First, use wix-data to get or query the collection for the row with the html in it. Then use postmessage on the html-component to hand over that html.

1 Like

So each item has it’s own HTML code?

  • If that’s the case, add a Rich Content column in your CMS.
  • Now add your HTML code for all the items / rows by selecting the Insert HTML Code </> option from the embeds panel at the bottom.
  • Then, in the editor, add a Rich Content Viewer element to your repeater / dynamic page and link it to the new field that you just created in the CMS, that has the HTML code.

If followed correctly, this should let you add a unique HTML code for each item in your CMS.

1 Like

Love both of these methods :raising_hands: