[Chameleon] How to include (join) php code in custom widget
Julien-Samuel Lacroix
jlacroix at mapgears.com
Mon Jan 22 14:30:18 EST 2007
Hi,
Sorry for the late response. Put your PHP where your $this->x=... is.
This will give you a widget file like the following. Note that I will
skip some part of the code to make the message shorter.
function ParseURL()
{
// execute parent function
parent::ParseURL();
// work some magic
if ( $this->isVarSet( "NAV_CMD" ) &&
$this->getVar( "NAV_CMD" ) == 'UUW' )
{
if ( $this->mszCoords == 'aa')
{
/////////////////////////////
// Put your code here
/////////////////////////////
$xml_file="./archivo4.xml";
$xml_data=implode("",file($xml_file));
//[...snip...]
for($j = 0; $j < $tot_b; $j++)
{
$sc_name = $xml->response->content->record[$j]->ScientificName->_value;
if($sc_name == "Inga oerstediana")
{
/////////////////////////////////////////////////////
/// Here//////////////
////////////////////////////////////////////////
$sc_name2= $xml->response->content->record[$j]->ScientificName->_value;
$this->y= $xml->response->content->record[$j]->Latitude->_value;
$this->x= $xml->response->content->record[$j]->Longitude->_value;
}
}
}
else
{
//////////////////// Note that! /////////
return false;
}
}
else
{
//////////////////// Note that! /////////
return false;
}
}
else
{
//////////////////// Note that! /////////
return false;
}
//$this->lb = $this->getVar('especie');
if ($this->isVarSet('espe') == 0)
{
$this->lb = "no";
}
else
{
$this->lb = $this->getVar('espe');
}
$poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
//[...snip...]
Ines wrote:
> Hi, I'm customizing my widget and have to include a php code in it to take
> the value of differents variables. I need to know in which place of the
> widget have I to write the code.
>
> This is my objective:
>
> 1) I have my custom widget yet. The objective of the widget is take a
> longitude and latitude (x, y) an draw a point in the map in that coords. I
> have this code and it works very well and I can see the point in the map. I
> solved it in the ParseURL() function but using x,y coords (variables) with a
> fixed value to prove. Ex: $this->x = -85; $this->y = 13;
>
> 2) Now, I have to take that values from a XML file to make the values of x
> and y variables (change the values of x and y) for draw the point layer in
> another coords. I have the code in php to read my XML file and it works very
> good, but not into the widget.
>
> 3) My question is: In wich place or where do I have to put my php code (to
> read my xml file) in the widget? to use the value of the variables that read
> the xml file of my php code. I need to join the widget with my php code. I
> see the widget have many functions. I tried to copy-paste my php code in
> the ParseUrl() function but it show me errors.
>
>
--
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/
More information about the Chameleon
mailing list