Page 1 of 1

[SOLVED] javascript vs smarty

Posted: Thu Sep 16, 2010 8:47 pm
by brentnl
Hi, I can't get this code to work:

Code: Select all

<__script__ type="text/javascript">
var key = '{$j}';
var videoid = '{$item->videoid}';

{literal}
  var flashvars = { file:'http://www.youtube.com/watch?v=videoid',autostart:'false' , image:'http://i.ytimg.com/vi/(videoid)/hqdefault.jpg',backcolor: '111111', frontcolor:'cccccc',lightcolor:'ff6600',skin:'http://www.longtailvideo.com/jw/upload/stylish.swf',controlbar:'over',stretching:'fill'};

  var params = { allowfullscreen:'true', allowscriptaccess:'always', wmode:'transparent' };

  var attributes = { id:'$videoid', name:'(videoid)'};
  swfobject.embedSWF('mediaplayer/player.swf','test','331','187','9.0.115','false',

    flashvars, params, attributes);

var player;
function playerReady(obj) {
[key] = document.getElementById(obj['id']);
};
{/literal}
</__script>
I want to use the variables 'key' en 'videoid' in the javascript code, because smarty tags aren't working inside the {literal} tag...
I've tried ['videoid'], ('videoid'), (videoid), "videoid", videoid, but nothing seems to work... What's wrong?

Re: javascript vs smarty

Posted: Thu Sep 16, 2010 9:01 pm
by Jos
If you want to use a smarty variable inside javascript you can do it like this:

Code: Select all

<__script__ type="text/javascript">
{literal}

some javascriptcode {/literal}{$item->videoid}{literal} some more javascript code

{/literal}
</__script>