Bonjour,
Je suis sous symfony 1.1 et j'utilise l'admin générator pour mon
backoffice.
J'utilise les plugins sfAdvancedAdminGeneratorPlugin et
sfEasyGMapPlugin.
J'ai bien suivi les instructions données sur "
http://www.symfony-
project.org/plugins/sfEasyGMapPlugin" mais j'ai l'erreur suivante :
"Undefined variable: gMap" dans mon partial.
En regardant le cache de _show.php j'ai la ligne suivante :
<?php $value = get_partial('map', array('type' => 'list', 'unite' =>
$unite)); echo $value ? $value : ' ' ?>
cela explique pourquoi j'ai Undefined variable sur $gMap parce que la
variable n'est pas transmise au partial dans le array.
Donc comment je dois procéder pour transmettre une variable à un
partial en gardant l'admin generator ?
Pour information si j'écris l'action dans mon partial en modifiant
bien sur $this->gMap par $gMap etc.. j'ai la carte qui s'affiche
correctement mais bon je suis pas sur que sa soit la meilleure façon
de faire.
J'ai dans mon generator.yml :
generator:
class: sfAdvancedAdminGenerator
param:
model_class: Unite
theme: default
show:
title: Visualisation de « %%nom%% »
display:
"Fiche": [nom, adresse, ville, _map]
actions:
_list:
_edit:
dans mon fichier actions.class.php :
class uniteActions extends autouniteActions
{
public function executeShow()
{
$this->unite = $this->getUniteOrCreate();
if ($this->unite->isNew()) {
return $this->forward('unite', 'create');
}
$this->labels = $this->getLabels();
// google maps
$this->gMap = new GMap();
$address = $this->unite->getAdresse().', '.$this->unite-
>getVille();
$geocoded_address = $this->gMap->geocode($address);
$gMapMarker = new GMapMarker($geocoded_address->getLat(),
$geocoded_address->getLng());
$gMapMarker->addHtmlInfoWindow('<b>'.$this->unite->getNom().'</
b><br />'.$address);
$this->gMap->addMarker($gMapMarker);
$this->gMap->setZoom(14);
$this->gMap->setCenter($lat,$lng);
}
}
et dans le partial _map.php :
use_helper('Javascript','GMap');
include_map($gMap,array('width'=>'100%','height'=>'450px'));
include_map_javascript($gMap);