Smartyを使用していますが、Googleマップを使用して、マーカーを動的に配置したいので、次のタラを取得しました
{literal}
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
// ==== first part of the select box ===
var select_html = '<select onChange="handleSelected(this)">' +
'<option selected> - Select a location - <\/option>';
// =====================================
var gmarkers = [];
var htmls = [];
var i = 0;
var rozmiar = new google.maps.Size(12,20);
var punkt_startowy = new google.maps.Point(0,0);
var punkt_zaczepienia = new google.maps.Point(0,0);
var map;
var n=0;
var side_bar_html = "";
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
var ikona1 = new GIcon(icon,"http://labs.google.com/ridefinder/images/mm_20_blue.png");
// A function to create the marker and set up the event window
function createMarker(point,name,html,ikon) {
var options = {
draggable: true,
title: name,
icon: ikon,
clickable:true}
var marker = new GMarker(point,options);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
gmarkers[i] = marker;
htmls[i] = html;
// ======= Add the entry to the select box =====
select_html += '<option> ' + name + '<\/option>';
// ==========================================================
i++;
map.addOverlay(marker);
return marker;
}
// ======= This function handles selections from the select box ====
// === If the dummy entry is selected, the info window is closed ==
function handleSelected(opt) {
var i = opt.selectedIndex - 1;
if (i > -1) {
GEvent.trigger(gmarkers[i],"click");
}
else {
map.closeInfoWindow();
}
}
var wspolrzedne = new google.maps.LatLng(51.730430542940184,19.62158203125);
// create the map
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.730430542940184,19.62158203125), 6);
{/literal}
{foreach from=$znacznik key=key item=item}
{foreach from=$item key=k item=v}
//here
createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);
//here
{/foreach}
{/foreach}
{literal}
}else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Community Church Javascript Team
// http://www.bisphamchurch.org.uk/
// http://econym.org.uk/gmap/
//]]>
</script>
{/literal}
タグ間(//ここ)これらのコードは問題です
createMarker(new GLatLng(51.730430542940184,19.62158203125),'{if $k == 'nazwa_obiektu'}{$v}{/if}','<div class="dymek"><div style="border-bottom:2px solid red;margin-bottom:6px;text-align:left;"><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/" style="color:#2A86C7;font-size:13px;font-family:Verdana;font-weight:bold;">{if $k == 'nazwa_obiektu'}{$v}{/if}</a></div></strong><div style="float:left;width:125px;"><strong><a href="http://nocleg-i.pl/{if $k == 'id'}{$v}{/if}/google_maps/"><img src="http://nocleg-i.pl/uzytkownicy/miroslawa/mini_0.jpg" alt="" border="0" /></a></div>Miasto: {if $k == 'miasto'}{$v}{/if}</div></div><div style="clear:both;"></div>',ikona1);
exの変数は表示されていません。{if $ k =='nazwa_obiektu'} {$ v} {/ if}何も表示されない場合、foreach関数を他の場所で実行すると、変数が表示されますが、手動で入力すると表示されます。誰かがそれを解決する方法を知っていましたか?