[SOLVED] javascript vs smarty

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
brentnl
Power Poster
Power Poster
Posts: 493
Joined: Mon May 11, 2009 4:35 pm

[SOLVED] javascript vs smarty

Post 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?
Last edited by brentnl on Thu Sep 16, 2010 9:26 pm, edited 1 time in total.
Jos
Support Guru
Support Guru
Posts: 4019
Joined: Wed Sep 05, 2007 8:03 pm

Re: javascript vs smarty

Post 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>
Post Reply

Return to “Layout and Design (CSS & HTML)”