Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Add Script Code To A Block Rate Topic   - - - - -

 
  • Ranger-1
  • Newbie
  • Trial users
  • Join Date: 20-Aug 11
  • 13 posts

Posted 30 August 2018 - 02:37 PM #1

 
Hi all,
 
We are looking for a way to add script to a block on the frontpage. We would like to add a link/button that triggers a pop-up subscribe page from mailchimp. I tried to add the code to HTML with smarty support, but I do get an error. The script code looks like this: 
 

<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,""script"",""https://chimpstatic.com/mcjs-connected/js/users/e53bd369a4a1838da85b30152/5fc5e133a4df479c81a7cd586.js"");</script> 

 
Any idea how to fix this?



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10945 posts

Posted 30 August 2018 - 08:11 PM #2

What's the error your getting?  The 'id' attribute will probably be removed.  I'd suggest since you have '{' and '}' on the same line that you need to utilize {literal} tags to prevent smarty from interpreting what's between the {}'s.  I.e.

{literal}
<script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,""script"",""https://chimpstatic.com/mcjs-connected/js/users/e53bd369a4a1838da85b30152/5fc5e133a4df479c81a7cd586.js"");</script> 
{/literal}
 

Alternatively you could break up the script into multiple lines.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.