News:

Wondering if this will always be free?  See why free is better.

Main Menu

Viglink Code Error

Started by Goad, December 17, 2010, 02:18:26 PM

Previous topic - Next topic

Goad

I am trying to insert the viglink code (www.viglink.com) into my forum, but its giving me an error...

I am using SMF 1.1.12

I am putting the following code right before the </body> tag...

<script type="text/javascript">
  var vglnk = { api_url: '//api.viglink.com/api',
                key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' };

  (function(d, t) {
    var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
    s.src = ('https:' == document.location.protocol ? vglnk.api_url :
             '//cdn.viglink.com/api') + '/vglnk.js';
    var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
  }(document, 'script'));
</script>


and I am getting the following error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/xxxxxx/public_html/xxxxxxx/Themes/default/index.template.php on line 615

Line 615 is the following line:                         key: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' };


Any suggestions?

DoctorMalboro

Shouldn't you ask this in the mod support topic?

Goad

Quote from: DoctorMalboro on December 17, 2010, 02:34:08 PM
Shouldn't you ask this in the mod support topic?

this isnt a MOD...and the question has nothing to do with a MOD

i am inserting code into my template. this is a code support section, right? if not, point me in the right direction.

DoctorMalboro

Ok... easy, mate... just asking.

try with this:
<script type="text/javascript">
  var vglnk = { api_url: \'//api.viglink.com/api\',
                key: \'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\' };

  (function(d, t) {
    var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
    s.src = (\'https:\' == document.location.protocol ? vglnk.api_url :
             \'//cdn.viglink.com/api\') + \'/vglnk.js\';
    var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
  }(document, \'script\'));
</script>

Goad

Quote from: DoctorMalboro on December 17, 2010, 04:49:55 PM
Ok... easy, mate... just asking.

try with this:
<script type="text/javascript">
  var vglnk = { api_url: \'//api.viglink.com/api\',
                key: \'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\' };

  (function(d, t) {
    var s = d.createElement(t); s.type = 'text/javascript'; s.async = true;
    s.src = (\'https:\' == document.location.protocol ? vglnk.api_url :
             \'//cdn.viglink.com/api\') + \'/vglnk.js\';
    var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
  }(document, \'script\'));
</script>


thanks man....initially it didnt work, but i saw what you were doing and got it working.....highlighted is my changes...

Quote<script type="text/javascript">
  var vglnk = { api_url: \'//api.viglink.com/api\',
                key: \'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\' };

  (function(d, t) {
    var s = d.createElement(t); s.type = \'text/javascript\'; s.async = true;
    s.src = (\'https:\' == document.location.protocol ? vglnk.api_url :
             \'//cdn.viglink.com/api\') + \'/vglnk.js\';
    var r = d.getElementsByTagName(t)[0]; r.parentNode.insertBefore(s, r);
  }(document, \'script\'));
</script>

DoctorMalboro

Yep, i did it pretty fast... sorry, remember that if you have any javascript that use ' in the middle of an echo''; use the slash to stop it from crashing your forum :)

Advertisement: