Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

strange problem with get element by id (widget)


Go to End


1523 Views

Avatar
snaip

Community Member, 181 Posts

5 September 2009 at 10:52pm

Edited: 05/09/2009 10:53pm

hi

i have widget to add differents pages

class ObiektyWidget extends Widget{
	static $title = "";
	static $cmsTitle = "Select object";
	static $description = "";

	static $db = array(
		"ObiektID" => "Varchar"
	);


	function getCMSFields(){
		return new FieldSet(			
			new SimpleTreeDropdownField('ObiektID','Select object:')
		);
	}

	function Objects(){
		$object = DataObject::get_by_id("SiteTree",$this->ObiektID);
		return $object;
	}	
}

in widget template

<% control Objects %>
	var marker = new GMarker(new GLatLng($Lat,$Lng),{title: "$Title"});
	mapa.addOverlay(marker);
			
	GEvent.addListener(marker,"click",function() {  
        	marker.openInfoWindowHtml('<div class="dymek"><h2>$Title</h2><% control Zdjecie %><% control CroppedImage(90,50) %><img title="" src="$URL" width="90" height="50" style="float: left; margin-right: 5px;" /><% end_control %><% end_control %><p>$Zajawka</p><p><a href="$Link">przeczytaj opis</a></p></div>');  
	});		
<% end_control %>

and everythig is ok
on my google maps i have all markers (object pages)
but when i click on marker window opens on last object (last widget in CMS) not on clicked

any idea how correct this problem ?