News:

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

Main Menu

Help with java in template file

Started by prodigal, October 27, 2007, 08:13:30 PM

Previous topic - Next topic

prodigal

Hi There ,

Im am attempting to add some java into my template so I can control ads from an external CSM , the code is as follows.

<div id="forum_header_ad">

<!-- Banner Code -->

<script type="text/javascript">
//<![CDATA[
var tags = "forum,site";
var region = "forumheader";
document.write( '<scr'+'ipt type="text/javascript" src="http://www.mydomain.com/ads/ad.js?tag=' + tags + '&amp;region=' + region + '&amp;m=j&amp;f='+FlashVersion+'"></scr'+'ipt>');
//]]>
</script>

<!-- End Banner Code -->

</div>


this in theory should work fine but when I attempt to save the template it is throwing up the following error

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in index.template.php on line 279


are there any tags I need to put around the java stuff to make it behave? any help much appreciated :D

sorry I should mention line 279 is


document.write( '<scr'+'ipt type="text/javascript" src="http://www.mydomain.com/ads/ad.js?tag=' + tags + '&amp;region=' + region + '&amp;m=j&amp;f='+FlashVersion+'"></scr'+'ipt>');
//]]>
[code]
[/code]

karlbenson

Depending on where your adding the code into smf it might need echoing in php
eg

echo 'YOUR CODE';

also all your single quotes need escaping with a backslash eg
echo 'document.write( '<scr\'+\'ipt type..... ';

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

prodigal

Sorry im no coder :) , thanks for your tips , am I on the right track with this


echo '
      <a href="'.$scripturl.'" title=""><span id="logo"><div id="forum_header_ad">
<!-- Banner Code -->
      <script type="text/javascript">
      //<![CDATA[
      var tags = "forum,site";
      var region = "forumheader";\
      document.write( '<scr\'+\'ipt type="text/javascript" src="http://www.back2basics.co.nz/ads/ad.js?tag=\' + tags + \'&amp;region=\' + region + \'&amp;m=j&amp;f=\'+FlashVersion+\'"></scr\'+\'ipt>');
      //]]>
      </script>
     
<!-- End Banner Code -->

</div>
</span></a>';

JayBachatero

Yea you are on the right track.  Missing two more though.


echo '
      <a href="'.$scripturl.'" title=""><span id="logo"><div id="forum_header_ad">
<!-- Banner Code -->
      <script type="text/javascript">
      //<![CDATA[
      var tags = "forum,site";
      var region = "forumheader";\
      document.write(\'<scr\'+\'ipt type="text/javascript" src="http://www.back2basics.co.nz/ads/ad.js?tag=\' + tags + \'&amp;region=\' + region + \'&amp;m=j&amp;f=\'+FlashVersion+\'"></scr\'+\'ipt>\');
      //]]>
      </script>
     
<!-- End Banner Code -->

</div>
</span></a>';
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

prodigal


Advertisement: