14/04/2012 4:35pm

PHP | Problem -


page:


<?php

class MarketPage extends Page {

static $has_many = array(
'Markets' => 'Market'
);
....

Conztroller:

class MarketPage_Controller extends MyController {


public function handleAction() {
$config = $this->SiteConfig();
Requirements::javascript("http://maps.googleapis.com/maps/api/js?key={$config->APIKEY}&sensor=true");
Requirements::javascript($this->PathwithTheme.'/js/google/marker-cluster.js');
$jsPois = "var poiArray = new Array();\n";
$i = 0;
$markets = $this->getMarkets();
Debug::dump($markets);
Debug::dump($this->Markets()->Store());
die();
foreach ($this->M->Store AS $poi) {
$jsPois .= "mapArray.push({
title:'".$poi->Title."',
lat:'".$poi->Latitude."',
lng:'".$poi->Longitude."',
url:'".$this->Object->Photo()->SetWidth(35)->URL."'
}); \n";
$i++;
}
Requirements::customScript($jsPois);

$data = array(


);

return $this->customise($data)->renderWith(array('MarketPage','MarketPage'));
}
template:

<% if Markets %>
<ul id="staff-list">
<% control Markets %>
<li>
<h2><a href="$ShowLink">$Name</a></h2>
<% if Store %>
<% control Store %>
$Latitude
<% end_control %>
<% end_if %>
</li>
<% end_control %>
</ul>
<% end_if %>


Post Comment