Hi!
Question:
I would like to insert external widgets on a dynamic page via code (the HTML code would be provided via CMS). The content of an HTML box can apparently not be changed via code (see API - https://www.wix.com/velo/reference/$w/htmlcomponent). Does anyone have an idea how else to do this? There are two lines involved:
<div (...) ></div>
<script async src="(...).js"></script>
Product:
Wix Editor
What have you already tried:
I had tried it with the HTMLComponent, but, as written, that doesn’t work.
Thanks & regards, Spektral
I don’t think this is possible. Can you share a bit more about your usecase though? There might be other ways to approach this problem.
For example if you have control over the code in your initial HTMLComponent then you can use postMessage
from Velo to send an event to the component that it can then respond to: https://www.wix.com/velo/reference/$w/htmlcomponent/postmessage
Hi @anthony,
Thank you for your feedback.
I have a dynamic page from which around 200 individual pages are created. I would like to insert an (affiliate) widget from viator on some pages, depending on the content of the dynamic page displayed. It would be perfect if I could save the calling code for the widget in the CMS and then pass it to the HTML box as required to display the widget.
But as you write, this is not possible. Just passing additional data to the html box with postmessage will probably not work either. I need the two (exemplary) lines in the HTML box from my first post.
A workaround would be to create several sections in the dynamic page and insert an html box with a specific widget in each. Then I could show only the section I want and hide the others (with collapse / expand). This would work, but would probably slow down the performance of the page the more sections there are (apart from the fact that it would not be very elegant).
Maybe you have another idea (or someone else)?
Best regards!
Update: I have found a solution, you can insert an html box into a rich content element and link the rich content box to the page via the cms.
1 Like