I am using with addressfield. It doesn't work with users or other entity

Comments

webankit’s picture

StatusFileSize
new5.44 KB

Working but on using bulk taxomonize getting this error
An AJAX HTTP error occurred. HTTP Result Code: 200 Debugging information follows. Path: /d7/batch?id=21&op=do StatusText: OK ResponseText: Fatal error: Class name must be a valid object or a string in /Applications/XAMPP/xamppfiles/htdocs/d7/includes/common.inc on line 7506

goron’s picture

Assigned: Unassigned » goron
Status: Active » Needs review
webflo’s picture

Status: Needs review » Needs work

I done a visual review. Never applied it.

+++ b/location_taxonomize.moduleundefined
@@ -397,18 +397,18 @@ function location_taxonomize_term_attach($tids, $form, &$form_state) {
+  // load the entity
+  $entity = entity_load($eid);

entity_load($eid) will fail. First parameter is entity_type.

+++ b/location_taxonomize.moduleundefined
@@ -397,18 +397,18 @@ function location_taxonomize_term_attach($tids, $form, &$form_state) {
+  entity_save($entity);

location_taxonomize has no dependency entity api.

+++ b/location_taxonomize_af/location_taxonomize_af.moduleundefined
@@ -145,11 +145,11 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
       $result = db_query("SELECT entity_id FROM {$table} WHERE entity_type = :etype AND bundle = :bundle ORDER BY entity_id ASC", $replace);
       $result_array = $result->fetchAllAssoc('entity_id');

Should be an entity field query.

+++ b/location_taxonomize_af/location_taxonomize_af.moduleundefined
@@ -167,19 +167,19 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
+      $entity = entity_load($eid);

entity_type is missing.

+++ b/location_taxonomize_af/location_taxonomize_af.moduleundefined
@@ -167,19 +167,19 @@ function location_taxonomize_af_bulk_taxonomize_op($form_state, &$context) {
+        $items = field_get_items('entity', $entity, $field);

this should be dynamic

goron’s picture

Assigned: goron » Unassigned
stevenx’s picture

#1 works OK for user entity with adressfield

deanflory’s picture

When I attempt to apply the patch, I get this response which is a fail:

patching file location_taxonomize.module
Hunk #1 succeeded at 153 (offset 9 lines).
Hunk #2 succeeded at 162 (offset 9 lines).
Hunk #3 succeeded at 382 (offset 11 lines).
Hunk #4 succeeded at 394 (offset 11 lines).
Hunk #5 FAILED at 408.
1 out of 5 hunks FAILED -- saving rejects to file location_taxonomize.module.rej
can't find file to patch at input line 70
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/location_taxonomize_af/location_taxonomize_af.module b/location_taxonomize_af/location_taxonomize_af.module
|index 2f20f71..53e76ea 100644
|--- a/location_taxonomize_af/location_taxonomize_af.module
|+++ b/location_taxonomize_af/location_taxonomize_af.module
--------------------------
File to patch:

Maybe I'm missing something but I generally don't have many problems with patches unless they're out-of-date with the current module file set. Any ideas on how to remedy this? Removing the a's and b's?

deanflory’s picture

Typing in "location_taxonomize_af/location_taxonomize_af.module" worked to complete the process but I'm still unsure of the practice of adding in what seems to be local development locations and not what is actually in downloads on the module page.

mbrakken’s picture

The patch is against an older version of the module, so the line numbers are no longer accurate. You can modify by hand (which is what I tend to do). Mostly, the patch finds and replaces "node" with "entity" and "nid" with "eid".

Since this is getting renewed attention, we should probably roll a new patch anyway and address issues raised in #3. I'm sure it won't get merged (and shouldn't) until at least that much is done.

johnv’s picture

sanchiz’s picture

Version: 7.x-2.2 » 7.x-2.4
StatusFileSize
new5.05 KB

New patch version , works with 2.4 module

johnv’s picture

@sanchiz, are you sure this is working? The comments in #3 are not addressed.
Especially entity_load($eid) will fail. First parameter is entity_type.

sanchiz’s picture

@johnv Indeed, bulk operation does not work properly, I'll correct it. Thank you!

sanchiz’s picture

Patch # 10 is not quite correct, that would earn the addition of the term when submitting the form, you need to comment out this line:

//Apply this only if we are on a node-edit form
//if (!isset($context['form']['#node_edit_form'])) return;

If this does not work bulk operation.

stevenx’s picture

How could we get it working with bulk operation?
I am note sure where to start to fix this issue

lonehorseend’s picture

#10 gives me these errors:

  • Notice: Undefined index: field_location in location_taxonomize_af_element_submitted() (line 106 of /location_taxonomize/location_taxonomize_af/location_taxonomize_af.module).
  • Warning: Invalid argument supplied for foreach() in location_taxonomize_af_element_submitted() (line 108 of /location_taxonomize/location_taxonomize_af/location_taxonomize_af.module).

If I don't follow the suggestion in #13.

Bulk update doesn't work.

And if I change the city in the address field on my profile2 form, it doesn't update the field_location_taxonomize_terms field, so I'm not sure the patch is working. Nodes still work as expected with the patch.

lonehorseend’s picture

Well, I fixed my problem and am now getting the message - "Location Taxonomize could not attach the terms to the entity because the Taxonomy Reference field is not set up correctly."

How did I solve my problem? Well, in locational_taxonomize_af.module there is a line that says "$deltas = $form_state['values'][$field][$lang];," which works fine for nodes because the $form_state['values'] has the field names. Profile 2 Entities, however, don't. (Not sure about the rest as all I want this to do is work for Nodes and Profile2 Entities) Field names in Profile2 Entities are stored under the first key in $form_state['values'] and are the machine name of the profile. So in line 104 of a #10 patched location_taxonmize_af.module I grabbed the array_keys of $form_state['values']:

<?php
$value_index = array_keys($form_state['values']);
?>

And then I changed the $deltas line below that to an if then else check:

<?php
  foreach ($fields as $field) {
    if ($value_index[0] != 'nid')
	{
		$deltas = $form_state['values'][$value_index[0]][$field][$lang];
	} else
	{
		$deltas = $form_state['values'][$field][$lang];
	};
?>

Once I get my new error figured out. I will roll a patch for the location_taxonomize_af.module

lonehorseend’s picture

Issue summary: View changes
StatusFileSize
new8.07 KB

Ok. Here's my patch. It combines #10 with the other modifications I made to get entities working. Bulk operations is still broken though, if someone wants to tackle that part of the problem.

deanflory’s picture

Here's what I got when trying to apply #17 to the latest dev version:

patch < supportotherentities.patch
(Stripping trailing CRs from patch.)
patching file location_taxonomize.inc
(Stripping trailing CRs from patch.)
patching file location_taxonomize.module
Hunk #1 succeeded at 150 (offset -6 lines).
Hunk #2 FAILED at 411.
1 out of 2 hunks FAILED -- saving rejects to file location_taxonomize.module.rej
(Stripping trailing CRs from patch.)
can't find file to patch at input line 129
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|--- \location_taxonomize_af\location_taxonomize_af.module 2012-06-03 22:30:00.000000000 -0800
|+++ \location_taxonomize_af\location_taxonomize_af.module 2013-11-16 17:41:05.000000000 -0800
--------------------------
File to patch:

caw67’s picture

Cant apply the patch #17

caw67’s picture

ok, patch #17 dont work for me!

sk2013’s picture

Any updates please?

Anonymous’s picture

StatusFileSize
new19.81 KB

Here is my attempt at making it fully entity aware.

The previous patches were only making changes for profile2, which isn't a true entity implementation.
I did try to take how profile2 set up its forms to process that data as well.

My testing was done with the address field module. I did not have any install that used the location module, but it looks pretty entity ready, but might not work with profile 2.

Some bigger changes came with how the bulk updating works, to keep track of entity_ids and entity_types.

Hope this helps.

sk2013’s picture

Thanks for the Work "rsmylski". Much appreciated

Anonymous’s picture

StatusFileSize
new33.06 KB

Was noticing some issues with bulk update. Updated my patch to resolve those.

Golem07’s picture

@rsmylski

Thanks for your work!

I am using an address field on core user profiles and am still encountering some problems with the association of terms with the users:

I have applied your patch to the latest dev version and checked the 'Taxonomize locations from this field' in the address field. After a bulk update the locations are entered into the location vobaulary fine as terms. However, the terms are not linked to the corresponding user profiles. I still get the "There is currently no content classified with this term" message when i click one of the entered terms.

Am I doing something wrong, or does the patch not cover user profiles (yet)?

Thanks in advance for your help!

k_zoltan’s picture

StatusFileSize
new32.82 KB

The patch of @rsmylski works for me with some minor corrections, so here is my version of that patch.

The problem is that some coding standards were not followed by the initial module and this is why the patch is that fuzzy.

k_zoltan’s picture

There is one additional problem with the entity support of this module.
Currently this acts on the form_submit hook, and if the module is created with some importing tool like feeds this could cause it not to work anymore.
I think it would be much better to rewrite and to act on entity_presave.

capfive’s picture

Tested and working with Profile2!!! thank you so much! helps for directory listings

attisan’s picture

Status: Needs work » Needs review
StatusFileSize
new33.59 KB

Re-rolling patch as 26 did not apply cleanly for me.

milesw’s picture

Patch #29 works great with CRM Core contact entities. Thanks for the patch.

furamag’s picture

Patch #29 works fine with users.

danzVP06’s picture

I tried Patch #29, It does not work with field collection.

kopeboy’s picture

Can we still get the users' support in and then think about field collection?