Developer forum

Forum » CMS - Standard features » Visual Editor and block that renders an Iframe

Visual Editor and block that renders an Iframe

Daniel Hollmann
Reply

Hi DW community.

We run a site for a customer on version 9.15.4. We have quit a bit of custom blocks that the customer can insert using the visual editor.

One of the blocks contains a simple section where the user can insert a Code snippet that could contain a script to render some external data.

They have now tried to use that to render a Google Map.
However, when this is shown in the visual editor, it does some weird stuff, that makes it almost impossible to insert other rows.
In this case the script, when rendered is displaying a Iframe. The Visual editor is also an Iframe, so maybe that is the issue?


Dynamicweb can’t of course make sure that the visual editor works for every scenario with a external script like this,
but what would be the best approach to prevent this?

 

I can see some of DW’s own modules uses: Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit") – to check if you are using the visual editor or not.
Would a viable solution be to use this an render a placeholder when inside the visual editor, so editing still works?

 


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Daniel,

It's a tricky one. Visual Editor is usually pretty robust against interference from the page, but there are, of course, limits.

I would not recommend using the query string parameter directly, rather you can use the PageView.IsVisualEditorMode property instead if you want to check the context. I would not recommend doing it too much as the logic in the templates could start to diverge between edit and view. But if you're careful, it shouldn't be a problem.

- Jeppe

 
Daniel Hollmann
Reply

Thanks. Yeah. I will use the PageView model instead, but I will see if it solves the problem. Thanks for your answer. :)

 

You must be logged in to post in the forum