We have now opened a commercial services section here on the forum for registered users. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.
Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.
For running J!5.1 you must https://fabrikar.com/forums/index.php?wiki/update-from-github/ or include the new file manually https://fabrikar.com/forums/index.php?threads/joomla-5-1-and-fabrik-cannot-find-files-error.54473/post-285151 See also Announcements
// Clean Start GM element
$VarStart = '{booking___start_address_coord}' ;
$MaVarStart2 = substr($VarStart, 0, strpos($VarStart, ":"));
$MaVarStart3 = str_replace('(' , '' , $MaVarStart2) ;
$MaVarStart4 = str_replace(')' , '' , $MaVarStart3) ;
$MaVarStart5 = str_replace(' ' , '%20' , $MaVarStart4) ;
$VarStart= $MaVarStart5 ;
// Clean End GM element
$VarArrival = '{booking___end_address_coord}' ;
$MaVarArrival2 = substr($VarArrival, 0, strpos($VarArrival, ":"));
$MaVarArrival3 = str_replace('(' , '' , $MaVarArrival2) ;
$MaVarArrival4 = str_replace(')' , '' , $MaVarArrival3) ;
$MaVarArrival5 = str_replace(' ' , '%20' , $MaVarArrival4) ;
$VarArrival= $MaVarArrival5 ;
// Create URL according GM API
$VarURLGM = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=$MaVarStart5&destinations=$MaVarArrival5" ;
// Read the JSON
//$obj = json_decode("$VarURLGM") ;
// Look up var
var_dump((string) $VarURLGM) ;
exit ;
// get the simple "lat,long" strings
$coords = FabrikString::mapStrToCoords('{booking___start_address_coord}') ;
$startCoords= $coords->lat . ',' . $coords->long;
$coords = FabrikString::mapStrToCoords('{booking___end_address_coord}') ;
$endCoords = $coords->lat . ',' . $coords->long;
//build the URL, with API key
$distanceURL = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=$startCoords&destinations=$endCoords&key=xxxxxxxxxxxxxxx" ;
// get the result and decode it
$distanceData = file_get_contents($distanceURL);
$distanceResult = json_decode($distanceData);
// test ... comment this out once you have the right URL and are getting sane JSON
var_dump($distanceURL, $distanceResult); exit;
// if result OK, grab the 'value' from the first row's first element data and stuff it into your distance element
if ($distanceResult->status === 'OK') {
$firstRow = FArrayHelper::getValue($distanceResults->rows, 0);
$firstElement = FArrayHelper::getValue($firstRow, 0);
$formModel->setFormData('booking___distance', $firstElement->distance->value);
}
// get the simple "lat,long" strings
$coords = FabrikString::mapStrToCoords('{booking___start_address_coord}') ;
$startCoords= $coords->lat . ',' . $coords->long;
$coords = FabrikString::mapStrToCoords('{booking___end_address_coord}') ;
$endCoords = $coords->lat . ',' . $coords->long;
//build the URL, with API key
$distanceURL = "https://maps.googleapis.com/maps/api/distancematrix/json?origins=$startCoords&destinations=$endCoords&key=MYKEY" ;
// get the result and decode it
$distanceData = file_get_contents($distanceURL);
$distanceResult = json_decode($distanceData);
$firstRow = FArrayHelper::getValue($distanceResults->rows,0);
$firstElement = FArrayHelper::getValue($firstRow,0);
// Test ... comment this out once you have the right URL and are getting sane JSON
var_dump($firstElement ); exit;
if ($distanceResult->status === 'OK') {
// get the first row, by using the array helper to get index 0, with an empty array as default
$firstRow = FArrayHelper::getValue($distanceResult->rows, 0, array());
// check to see if the result is empty
if (!empty($firstRow)) {
// if we got the first row, get the first element from it
$firstElement = FArrayHelper::getValue($firstRow, 0);
if (!empty($firstElement)) {
// if we got the element, get the distance
$formModel->setFormData('booking___distance', $firstElement->distance->value);
}
}
}