Chris74 Posted June 15, 2013 Share Posted June 15, 2013 Hi, I'm having a problem integrating the new twitter timeline widget in the footer of my WHMCS site. This works fine in a plain HTML page, but not inside WHMCS. The widget code consists of a hyperlink tag and a javascript tag. The javascript is as follows... <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> In WHMCS, viewing the javascript console - this comes up as a syntax error - it is as if WHMCS is stripping out some of the javascript... SyntaxError: syntax error [break On This Error] !function(d,s,id)}(document,"script","twitter-wjs"); In a normal HTML page, inspecting the surrounding div with firebug shows that the hyperlink tag has correctly changed into an iframe with the twitter feed in. The script tag contains the full javascript above. With WHMCS it shows the hyperlink in its raw state and the script tag only contains the following... !function(d,s,id)}(document,"script","twitter-wjs"); I've looked around for a solution but so far I've drawn a blank. Any suggestions would be gratefully received. 0 Quote Link to comment Share on other sites More sharing options...
Chris74 Posted June 15, 2013 Author Share Posted June 15, 2013 Some further searching revealed that inside the WHMCS template you need to place {literal} {/literal} tags around the javascript code. Sorted. 0 Quote Link to comment Share on other sites More sharing options...
panacheweb Posted June 15, 2013 Share Posted June 15, 2013 yes this is due to the use of smarty coding.. I honestly question how smart it is as I find it a pita to deal with... 0 Quote Link to comment Share on other sites More sharing options...
And then there was one les Posted June 16, 2013 Share Posted June 16, 2013 (edited) This has been a long standing issue with smarty templates. I really cant see why they need literal tags for script blocks, they already have tags that could easily be used to identify the code correctly. <script></script> Id just makes no sense to me at all why they insist on another tag being used. We dont have to use it for any other html tag so why these i will never understand. One thing that really sits foul with me is this sort of thing. {literal} <script> jQuery(function(){ jQuery('#dosomething').attr('{/literal}{$oh_damnit_i_need_this}{literal}'); }); </script> {/literal} There is just no need for such dismal hackery, smarty needs to get smart! Edited June 16, 2013 by CDJ Hosting 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.