[pmwiki-users] Page Variables help - how to take one and split into two
stevecrisp at gmail.com
stevecrisp at gmail.com
Sun Nov 1 11:04:14 CST 2009
Dear all,
I'm trying create two page variables from a new markup I've created (ref
GeoTagging recipe in development). The markup is as follows and represents
a comma separated latitude and longitude:
(:coord 50.1234, -2.3456:)
I'm trying (and failing) to take the value from coord and split it to store
two page variable called Latitude and Longitude. A logical example of what
I'm trying is below. Obviously it doesn't work so only for illustrative
purposes. I'd like to take the $FmtPV['$Coord'] and create
$FmtPV['$Latitude'] and $FmtPV['$Longitude']. As you can see I'm using
explode() via a function so I can extract element 0 (lat) and element 1
(lng).
$FmtPV['$Coord'] = '@$page["coord"]';
$SaveProperties[] = 'coord';
$FmtPV['$Latitude'] = 'function:GetLatFromCoord';
function GetLatFromCoord() {
$coordArr = explode(',',$FmtPV['$Coord']);
return $coordArr[0];
}
$FmtPV['$Longitude'] = 'function:GetLngFromCoord';
function GetLngFromCoord() {
$coordArr = explode(',',$FmtPV['$Coord']);
return $coordArr[1];
}
If this can done in a one-liner that would be even better. e.g.:
$FmtPV['$Latitude'] = 'explode(',',$FmtPV['$Coord'])'[0];
$FmtPV['$Longitude'] = 'explode(',',$FmtPV['$Coord'])'[1];
Thanks in advance for any pointers.
--Steve.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20091101/ecc76bff/attachment.html
More information about the pmwiki-users
mailing list