Ergebnis 1 bis 4 von 4

Thema: Fehler: ZERO_RESULTS | Geokoordinaten automatisch über DCA in Feld eintragen

  1. #1
    Contao-Nutzer
    Registriert seit
    29.09.2010.
    Ort
    Oberstdorf
    Beiträge
    78

    Standard Fehler: ZERO_RESULTS | Geokoordinaten automatisch über DCA in Feld eintragen

    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

  2. #2
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Bei Google hat sich was geändert, die wollen jetzt wieder einen API-Key haben. Die neue dlh_googlemaps 2.2.0 ist bereits daraufhin angepasst. Inwieweit MM da jetzt evtl. nochmal eigenen Code mitbringt weiß ich nicht. Und nach Update von dlh_googlemaps, solltest du auf angepasste Templates kontrollieren.

    Nachdem du von Google einen API-Key für die Domain bekommen hast, kannst du ihn im Startpunkt der Website eintragen.
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

  3. #3
    Contao-Nutzer
    Registriert seit
    29.09.2010.
    Ort
    Oberstdorf
    Beiträge
    78

    Standard

    Danke ja das mit dem API Key wusste ich schon, bekomme allerdings Fehlermeldungen
    wenn ich auf die neueste Version von der Erweiterung gehe.

    Ich vermute eher, das sich bei Contao etwas geändert hat und ich da keine Ahnung
    habe wo man das abgleichen kann. Evtl. gibt es da Änderungen bei den Funktionen oder so.

  4. #4
    Contao-Urgestein Avatar von Andreas
    Registriert seit
    19.06.2009.
    Ort
    Mönchengladbach
    Beiträge
    7.703
    User beschenken
    Wunschliste
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Ok, dann kann ich dir wahrscheinlich nicht weiterhelfen. Dass es an Contao liegt kann ich mir nicht vorstellen. Am besten debuggst du die Variablen in dem HOOK mal Schritt für Schritt. Oder mach mal ein hardcodiertes
    PHP-Code:
    return \delahaye\GeoCode::getCoordinates('Bundestag, Berlin'''''); 
    da rein.
    Bitte!
    Vor Anfragen im Forum HTML validieren.
    Codesnippets hier im Froum sauber einrücken. Nur Tabs o. nur Leerzeichen verwenden.

    Vielen Dank an alle Wunschlistenerfüller
    Andreas Burg, Web Solutions

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •