On my website I have a content type called beta and there are an approx of 30k beta nodes containing 40+ GBs of data. I converted my old website to drupal with a lot of needed tricks and techniques around an year ago.
However, I am stuck with a problem. The beta content type has over a dozen cck fields. Many of these fields have repeating data i.e. recurring in several beta nodes. I had earlier planned to use taxonomy and link these cck fields with terms/vocabularies. The pursuit of this goal has led to several problems.
Problems being
I)Out of all the modules I tried there is no module which allows for conversion of a cck 'text field type' in a certain content type to a 'free tagging taxonomy type'. The task would have been extremely simple if it were not so.
II)I think there is no module yet which allows for search data in the database to be used for the purposes of taxonomy. I would be really glad if there were a module which allowed for search index data to be used for taxonomy terms or something like a search engine vocabulary,etc.
Although I can think of few possible ad hoc solutions but it will be appreciable if there were a proper set of rules to follow here.
Comments
Comment #1
canadrian commentedDefinitely looking for this as well.
Comment #2
dberzon commentedMe too..........
Comment #3
asb commentedsubscribing
Comment #4
CobraMP commentedviews bulk operations
create the taxonomy and values
filter content type to a single value of the field you want to convert
using vbo set the taxonomy field to that entry
repeat for each value
update all your views to use taxonomy field instead of cck field
then hide the cck field so it no longer gets seen
Comment #5
niccottrell commented@CobraMP - Thanks for the instructions! I'm almost there, however I'm having trouble settings the taxonomy field. Firstly, I'm using the "Content Taxonomy module" which lets me create a field with a given taxonomy (rather than attaching to the whole node). However, the real problem is converted the value of the textfield into a term ID that I can save with node_save. Is there a neat function for taking a vocabulary and a string and returning the tid, inserting the missing term if necessary?
Comment #6
niccottrell commentedAfter many hours, I found a way. field_donor contains a text value, and I wanted save a taxonomy term into a new field_donor2
====
$vid = 25; // vocab ID
$edit = array('vid' => $vid, 'name' => $object->field_donor[0]['value']);
$terms = taxonomy_get_term_by_name($edit['name']);
if (!empty($terms)) {
// term already exists
$tid = $terms[0]->tid;
} else {
// add term and get the tid
$status = taxonomy_save_term($edit);
$tid = $edit['tid'];
}
$object->field_donor2[0]['value'] = $tid;
node_save($object);
===
I hope this helps someone else!
Comment #7
z33k3r commented@CobraMP - So obvious yet so distant when you're not on that thought pattern. Thanks!
Comment #8
alihammad commentedWhile going through the old threads I started here, I was so glad to see that this issue was actually RESOLVED although I had found a solution which didn't use the drupal api a while back.
It took 2 major drupal core upgrades and around 2 years but like always DRUPAL community triumphs at giving.
I am marking this as fixed.
Comment #10
ingomueller.net commentedSince I just spent some time in making this work in Drupal 7, I want to share my solution. Maybe it helps somebody...
Besides porting it to Drupal 7 API, I adapted above code to find the vocabulary ID automatically and to work with fields with multiple values:
Also I needed to figure out how to have this code run on every account. My solution was to create a Rule (with the Rules module) that is triggered "Before saving a user account" and with an "Execute custom PHP code" action with above code. To enable this kind of action, the "PHP filter" module from Drupal core needs to be activated. This converts the text field 'field_multi_text' to the field of term references 'field_multi_term_ref' when I import my users from CSV.
There are still a few assumptions hard coded. Suggestions welcome to improve the code...
Comment #11
ingomueller.net commentedI realize now that most (of not all) of what I coded by hand can actually be done by the Rules module out of the box, which would be much cleaner. So don't follow my example...