Post

2 followers Follow
0
Avatar

Can I use ONTRAform code in a Divi Code Block?

Frank Hagan

I use Divi, a theme from Elegant Themes on one site, and Divi Builder in other themes by them. It has a "code block" that is supposed to work with JavaScript code. But when I put the code for my ONTRAform in a code block, it remains blank!

Answered

Official comment

Avatar

ElegantThemes has fixed the issue - kudos to our Support Super Hero Lance for getting code samples over to them. Our form code will now work without any modification. 

Update your theme if you are still having an issue!

Frank Hagan
Comment actions Permalink

Please to leave a comment.

4 comments

0
Avatar

ONTRAPORT uses single quote marks in it's JavaScript code, like this:


<script type='text/javascript' async='true' 
src='https://app.ontraport.com/js/ontraport/opt_assets/drivers/opf.js'
data-opf-uid='p2c83585f36' data-opf-params='borderColor=#fff&
borderSize=5px&embed=true&formHeight=761&formWidth=480px&
popPosition=mc&instance=549867860'>
</script>

Divi uses single quotes in their function that is calling the code block, so it fails. If you have a JavaScript programmer available, you can have him switch the ONTRAPORT JavaScript code to use double quotes. This isn't as simple as it seems, and should be done by someone familiar with programming in JavaScript.


In addition to simply replacing each single quote with a double quote, the programmer will have to be able to recognize when a single quote is intended to be in the output and is "escaped" in the code, such as in the string 'Bob/'s your uncle'. The programmer will know how to handle that, and will also recognize when a double quote already in the code will need to be escaped. Fortunately, in the example code block shown here, we can simply replace single quotes with double quotes and try it. Copy the JavaScript to a text editor and make the changes. It now looks like this:


<script type="text/javascript" async="true" 
src="https://app.ontraport.com/js/ontraport/opt_assets/drivers/opf.js"
data-opf-uid="p2c83585f36" data-opf-params="borderColor=#fff&borderSize=5px
&embed=true&formHeight=761&formWidth=480px&popPosition=mc&instance=549867860">
</script>

Try the newly edited code in the Divi code block and see if it renders the form correctly. Like anything in the "custom coding" realm, we cannot guarantee results, and cannot do any custom coding for you.

Frank Hagan 0 votes
Comment actions Permalink
0
Avatar

Frank, I too am using Divi (and OP) for multiple sites and have encountered this problem.

I'm wondering how your experience has been implementing the "double quote" change as recommended by the moderator who replied to your question. Care to provide followup feedback?

Chris Lakey 0 votes
Comment actions Permalink
0
Avatar

It has worked in all cases that I know of, but let me know if it hasn't worked for you. Usually if it doesn't work it's because of a string that has something like an apostrophe (single quote) or quotation marks (double quote) that has to be "escaped" as mentioned in the article. 

Frank Hagan 0 votes
Comment actions Permalink