Using module with Getlocations - Location taxonomize

After entering [country] with point, island for example "о. Маврикий".

I getting error
Notice: Trying to get property of non-object in _find_term() (line 250
+
Terms creating
na-text
--na-text

Here is fix code:

location_taxonomize.module

-    // for all other terms (one parent is assumed):
-    elseif (array_pop($parents)->tid == $parentid) $withparent[] = $term;
+    // For all other terms (one parent is assumed).
+    else {
+      $parent = array_pop($parents);
+      // Make sure we actually had a parent before comparing.
+      if (!empty($parent->tid) && $parent->tid == $parentid) {
+        $withparent[] = $term;
+      }
+    }

// taken from part of patch https://www.drupal.org/node/2144313

with addition code for island without country )

function _location_taxonomize_create_term_name($hlevel_name, &$location, &$settings) {
  // convert this hlevel_name to an internal primary field name if necessary
  $field_name = location_taxonomize_convert_field_name($hlevel_name);
  switch ($field_name) {
    case 'country':
      if (empty($location[$hlevel_name])) {
        $name = $settings['na_text'];
      }
+    if (empty($location[$hlevel_name]) && !empty($location['country_name']) ) {
+	  $name = $location[location_taxonomize_source_field_name('country_name')];
+    }

Hope it will help somebody.

Comments

NIKS_Artreaktor created an issue. See original summary.

kamalrajsahu21’s picture

StatusFileSize
new785 bytes

Here is the patch for the solution

NIKS_Artreaktor’s picture

kamalrajsahu21

Thank for the patch, but it not correct enough.

Why lines are deleting?

-      if (empty($location[$hlevel_name])) {
-        $name = $settings['na_text'];

This lines have to be in code I guess.

---Plus---
add and delete this lines

-    // for all other terms (one parent is assumed):
-    elseif (array_pop($parents)->tid == $parentid) $withparent[] = $term;
+    // For all other terms (one parent is assumed).
+    else {
+      $parent = array_pop($parents);
+      // Make sure we actually had a parent before comparing.
+      if (!empty($parent->tid) && $parent->tid == $parentid) {
+        $withparent[] = $term;
+      }
+    }
kamalrajsahu21’s picture

StatusFileSize
new1.25 KB

#NIKS_Artreaktor

Sorry I forgot that code. Now I added that code on patch, also i change if condition to else if

+ elseif (empty($location[$hlevel_name]) && !empty($location['country_name']) ) {
+ $name = $location[location_taxonomize_source_field_name('country_name')];
+ }

thanks

ptmkenny’s picture

There's a more complex patch here: #2144313: Notice: Undefined index & Notice: Trying to get property of non-object. Need to decide which to adopt, since they are mutually exclusive.