Ich hatte ein Update auf einer Seite durchgeführt. Contao von 2.x auf 3.5.15
Metamodels wurde auch entsprechend auf die aktuelle 2.0.0 gezogen.
Ich hatte damals auch nach Vorlage folgendem Tutorial die dcaconfig angepasst
und eine entsprechende Klasse angelegt.
http://metamodels.pyropixel.de/news-...al-part-8.html
dcaconfig.php
PHP-Code:
$GLOBALS['TL_DCA']['mm_hotel']['fields']['th_geolocation']['save_callback'][] = array('Assets','convertAddressToGeocode');
Assets.php
PHP-Code:
<?php
class Assets
{
public function convertAddressToGeocode()
{
// get the field names for the address and geolocation
$strFieldnameAddress = "th_street";
$strFieldnamePLZ = "th_PLZ";
$strFieldnameGeocode = "th_geolocation";
// NEW METAMODEL ENTRY
// if a new metamodel has been created
// on a new metamodel entry ther is no id to identify the form data
// on a new entry each form field adds a '_b' at the end of it's name
if ( \Input::get('act')=='create' )
{
// get the new address data
$strAddress = \Input::post($strFieldnameAddress ."_b").' ';
$strAddress = \Input::post($strFieldnamePLZ ."_b").' '.$strAddress;
// get the new gelocation data
$strGeocode = \Input::post($strFieldnameGeocode ."_b");
// when creating a new asset, normally the geocode data would be empty
// but if the user enters manually a geocode, we don't want to overwrite it
// so we return the geocode, if the user has typed it in
if ( ! empty($strGeocode) ){ return $strGeocode; }
// if no address has typed in on a newly created entry, we cannot calculate a geocoordinate
// so we just return an empt string
if ( empty($strAddress) ){ return ''; }
// address && empty geocode -> calculate new geocode and return it
if ( ! empty($strAddress) && empty($strGeocode) )
{
// convert any linebreak in the address to a comma
$strAddress = preg_replace( "/\r|\n/", ", ", $strAddress );
return \delahaye\GeoCode::getCoordinates($strAddress, '', '');
}
// EDIT METAMODEL ENTRY
// if an existing metamodel has been edited
// on an existing metamodel entry there is a id to identify the form data
// on an existing entry each form field adds its 'id' at the end of it's name
// e.g. address_1 for the address field of dataset with id=1
}else{
// get the id of the metamodel entry that has been edited
$id = \Input::get('id');
// get the edited address data
$strAddress = \Input::post($strFieldnameAddress ."_" .$id);
$strAddress = \Input::post($strFieldnamePLZ ."_" .$id).' '.$strAddress;
// get the edited gelocation data
$strGeocode = \Input::post($strFieldnameGeocode ."_" .$id);
// address && empty geocode -> calculate new geocode and return it
if ( ! empty($strAddress) && empty($strGeocode) )
{
// convert any linebreak in the address to a comma
$strAddress = preg_replace( "/\r|\n/", ", ", $strAddress );
return \delahaye\GeoCode::getCoordinates($strAddress, '', '');
}
// address && geocode -> return the geocode (no overwrite geocode string)
if ( ! empty($strAddress) && ! empty($strGeocode) ){ return $strGeocode; }
// empty address && geocode -> return the geocode (no overwite geocode string)
if ( empty($strAddress) && ! empty($strGeocode) ){ return $strGeocode; }
}
return '';
}
}
Gibt es hier bei Contao 3.5.15 eine Änderung? Bin da leider zu wenig Programmierer.
Wenn ich nun den Datensatz in MM öffne ist das Geokoordinatenfeld leer und beim Speichern
kommt die Fehlermeldung ZERO_RESULTS.
Danke für die Hilfe im Voraus!
Contao 3.5.15
MM 2.0.0
dlh_googlemaps 2.1.1
Lesezeichen