Guest Posted March 23, 2014 Share Posted March 23, 2014 Can anyone advise where I would add some script code in 1.6 The code is for a live chat system. The instructions say add this to your "html" <!--Start of Tawk.to Script--> <script type="text/javascript"> var $_Tawk_API={},$_Tawk_LoadStart=new Date(); (function(){ var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0]; s1.async=true; s1.charset='UTF-8'; s1.setAttribute('crossorigin','*'); s0.parentNode.insertBefore(s1,s0); })(); </script> <!--End of Tawk.to Script--> Link to comment Share on other sites More sharing options...
El Patron Posted March 23, 2014 Share Posted March 23, 2014 add the code above below <head> tag in themes/yourtheme/header.tpl Link to comment Share on other sites More sharing options...
El Patron Posted March 23, 2014 Share Posted March 23, 2014 for better performance, use my instructions above and update the footer.tpl file. This is not possible for all java but most times it's ok. Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 ...and don't forget to put {literal} and {/literal} smarty tags around. Link to comment Share on other sites More sharing options...
El Patron Posted March 23, 2014 Share Posted March 23, 2014 I don't think literal is necessary...though I know at one time is was... this from review of native header.tpl and custom theme header.tpl there were no literal tags, which is weird.... Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2014 Share Posted March 23, 2014 Thanks for the reply. I tried in the header, but it does not work. I can see the code in source, and it has changed to <script type="text/javascript">/* <![CDATA[ */var $_Tawk_API={},$_Tawk_LoadStart=new Date();(function(){var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];s1.async=true;s1.src='https://embed.tawk.to//default';s1.charset='UTF-8';s1.setAttribute('crossorigin','*');s0.parentNode.insertBefore(s1,s0);})(); Would that be right? There does not seem to be an </script> tag to close the script Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 (edited) I don't think literal is necessary...though I know at one time is was... Good point! I've just prove it myself. I think this requirement is gone since Smarty 3.x which means my suggestion applies only to PS 1.3 and partially to PS 1.4. Edited March 23, 2014 by inweb (see edit history) Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 Thanks for the reply. I tried in the header, but it does not work. I can see the code in source, and it has changed to Try the literal tag. If the problem persists then please post us you web site URL. Are you using CloudFlare? Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2014 Share Posted March 23, 2014 Literal tags make no difference http://www.u-bolts-r-us.co.uk/ I should say the code works in 1.5 (I used Veika's html block, but that no longer works - needs an update for tinymce i think) Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 Then try in Back Office - Advanced Parameters - Performance disable "Compress inline JavaScript in HTML". Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2014 Share Posted March 23, 2014 Still no effect I am afraid Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 Then try the same with Minify HTML. Link to comment Share on other sites More sharing options...
El Patron Posted March 23, 2014 Share Posted March 23, 2014 it appears you area missing the ending </script> post the code from header.tpl you are using... Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2014 Share Posted March 23, 2014 it appears you area missing the ending </script> post the code from header.tpl you are using... I have put the code in the header.tpl as you said, the </script> tag is there as you can see here <html lang="{$lang_iso}"> <head> <!--Start of Tawk.to Script--> <script type="text/javascript"> var $_Tawk_API={},$_Tawk_LoadStart=new Date(); (function(){ var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0]; s1.async=true; s1.src='https://embed.tawk.to/52c482f0420ef4ad3a0000c0/default'; s1.charset='UTF-8'; s1.setAttribute('crossorigin','*'); s0.parentNode.insertBefore(s1,s0); })(); </script> <!--End of Tawk.to Script--> <meta charset="utf-8" /> <title>{$meta_title|escape:'html':'UTF-8'}</title> {if isset($meta_description) AND $meta_description} Link to comment Share on other sites More sharing options...
El Patron Posted March 23, 2014 Share Posted March 23, 2014 ok, so I just tested and in 1.6 even when in header.tpl it is moving the code to bottom...at this time I am not familiar enough with 1.6 to know how it is moving inline...hopefully someone with more 1.6 experience can help...I will report back if I can come up with something http://screencast.com/t/eTVo20JAo4 Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2014 Share Posted March 23, 2014 OK, thanks for your help anyway - personally I think it is related to why all the modules are not updating and cant configure in 1.5 and 1.6 lets see what the next few days brings Link to comment Share on other sites More sharing options...
inweb Posted March 23, 2014 Share Posted March 23, 2014 Well that JS code is moved to the end of the HTML source code by smartyOutputContent() method in classes/controller/Controller.php file. You can disable it by changing: $dom_available = extension_loaded('dom') ? true : false;to //$dom_available = extension_loaded('dom') ? true : false; $dom_available = false; However it should not cause any issues, it does not really matter where Tawk.to JS is executed. 1 Link to comment Share on other sites More sharing options...
felixdpg Posted March 26, 2014 Share Posted March 26, 2014 Hi inweb: I cant mark your reply as correct solution but I say you that is working ok for me. Thanks and regards Felix Link to comment Share on other sites More sharing options...
Recommended Posts