Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » strange problem with get element by id (widget)

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

Page: 1
Go to End
Author Topic: 900 Views
  • snaip
    Avatar
    Community Member
    180 Posts

    strange problem with get element by id (widget) Link to this post

    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 ?

    900 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.