2

I'm assigning taxonomy terms to an entity (user) like this:

$drupalUser->taxonomy_vocabulary_6 = array('und' => array(0 => array('tid' => _findorcreate_tid($eecid, $arrUser[12]))));

_findorcreate_tid finds, or creates a new tid, within the supplied vocabulary. This function is working correctly. $eecid is the vocabulary ID. $arrUser is some user data imported from a CSV.

When viewing the user object, the correct term name and ID is displayed, but viewing the term's "contents" (at a URL like http://localhost/taxonomy/term/1061), I'm told there is no content.

My very amateur poking around leads me to believe that the taxonomy_index table is not getting populated when I assign the terms in this manner.

I have tried to call taxonomy_build_node_index($drupalUser); after the user object is saved, but this has yielded no change (and I'm a bit unclear if that function only applies to nodes, or any entity).

Is there a better way of assigning taxonomy terms to a user entity that would fix this?

1 Answer 1

1

You're correct. The core taxonomy module doesn't index or display entities other than nodes. taxonomy_build_node_index() is only for nodes.

It sounds like the solution you're looking for is Taxonomy Entity Index.

The Taxonomy Entity Index module maintains a normalized index of all terms associated with a specific entity and revision. The core {taxonomy_index} table only maintains its data for published nodes. This module maintains its data for all entity types (regardless of published or not) and also indexed by revision.

It also supports views integration so you should be able to create a view of users who have been tagged with your taxonomy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.