Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  189] [ 4]  / answers: 1 / hits: 22603  / 14 Years ago, wed, august 4, 2010, 12:00:00

I am trying to use smarty variables inside javascript inside tpl



{literal}
<script language=javascript>
google.load('visualization','1',{'packages': ['geomap']});
google.setOnLoadCallback(drawMap);


function drawMap() {
var data = new google.visualization.DataTable();
data.addRows(4);
data.addColumn('string', 'Location');
data.addColumn('number', 'Number of links');

{/literal}{foreach from=$last5 item=link name=links key=index}
data.setValue({$index},0,'{$link.location|replace:''':'\''}');
data.setValue({$index},1,{$link.location_count});
{/foreach}{literal}

var options = {};
options['dataMode'] = 'regions';
options['region'] = 'world';

var container = document.getElementById('map');
var geomap = new google.visualization.GeoMap(container);

geomap.draw(data, options);
};
</script>
{/literal}


can you suggest me a solution please


More From » smarty

 Answers
5

Simply close the {literal} tag right before inserting the smarty variable, and re-open it again.



Or use {ldelim} and {rdelim} for the pieces of code where you assign values from Smarty.


[#96027] Monday, August 2, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristinsonjab

Total Points: 364
Total Questions: 98
Total Answers: 98

Location: Christmas Island
Member since Mon, Oct 19, 2020
4 Years ago
kristinsonjab questions
Fri, Mar 4, 22, 00:00, 2 Years ago
Fri, Jan 22, 21, 00:00, 3 Years ago
Fri, Aug 14, 20, 00:00, 4 Years ago
;