tascam424 Posted February 5, 2014 Share Posted February 5, 2014 Hi folks, i'm trying desperately to convert an HTML template to a Smarty Template for WHMCS, everything is going fine except i can't get the Parallax Slider to function. It works perfectly in the standard HTML Template but won't work in the Smarty Template, so i'm guessing some of the core WHMCS scripting must be conflicting. The only thing i can see is Uncaught SyntaxError: Unexpected token ) ultrawebtemplates.com/ :94 Lines 94 - 106 look like this <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script> <script type="text/javascript"> $(function() { $('#da-slider').cslider({ autoplay : true, bgincrement : 450 }); }); </script> Off course if anybody would care to look you can see the live domain http://ultrawebtemplates.com Greatly appreciate any help. Quote Link to comment https://forums.phpfreaks.com/topic/285966-uncaught-syntaxerror-unexpected-token/ Share on other sites More sharing options...
kicken Posted February 5, 2014 Share Posted February 5, 2014 Surround your script tags with smarty's {literal}...{/literal} tags What's happening is smarty is treating the { and } in the script as smarty tags and replacing them. If you view-source on your page you will see that the code is actually: <script type="text/javascript"> $(function() ); }); </script> Quote Link to comment https://forums.phpfreaks.com/topic/285966-uncaught-syntaxerror-unexpected-token/#findComment-1467875 Share on other sites More sharing options...
tascam424 Posted February 5, 2014 Author Share Posted February 5, 2014 Have you ever been told how wonderful you are ? Thank you so very much !! Worked perfectly just by adding that to the little piece of script. Is it necessary to do that when calling a script library also ? Like this <script type="text/javascript" src="templates/Custom/js/jquery.cslider.js"></script> It wasn't required in this circumstance but it it best practice ? Thank you again !! Quote Link to comment https://forums.phpfreaks.com/topic/285966-uncaught-syntaxerror-unexpected-token/#findComment-1467876 Share on other sites More sharing options...
kicken Posted February 5, 2014 Share Posted February 5, 2014 Is it necessary to do that when calling a script library also ?No, the script tags importing external files do not contain any { } pairs so they are not affected by smarty. Neither are the external files referenced as they are not parsed by smarty. Online inline scripts (or anywhere else you use { } pairs) needs to be wrapped in the literal tags. Quote Link to comment https://forums.phpfreaks.com/topic/285966-uncaught-syntaxerror-unexpected-token/#findComment-1467884 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.