Hello everyone,

Looking at the Module User Plus, I was wondering if there is an equivalent for taxonomy terms. I could find none.

I tried the Module Taxonomy import/export via XML, editing the XML file and then trying to import it. I failed :)

Is there any other method of editing the taxonomy terms quickly (accessing the database directly, maybe)?

Any method would be warmly welcomed!

Thank you very much in advance,

Felix.

Comments

felixsmile’s picture

If there is any way how I could also edit the users in a quicker way than using the users plus module, I would be very thankful. I thought about direct database access or something of the kind, I don't know.

Maybe also a solution like in many mailinglist systems, where there is a blank field, where you can copy paste a text: every line one user, with e-mail-address and user name.

I would be grateful for any suggestion, as this can be a very time-consuming matter otherwise.

Thanks in advance,

Felix.

felixsmile’s picture

Excuse me if I'm asking this question again: is there no one who knows how to edit Taxonomy Terms in a quicker way than adding them one by one via the administrator interface? If anyone has a solution for the user editing, I would be glad, too.

Please help me, I don't even want to think about editing the Taxonomy Terms one by one...

Thank you very much in advance,

Felix.

felixsmile’s picture

Excuse me if I'm talking to myself, I'm trying to find a solution which might help others, that's why I'm posting everything here. Please tell me if I am breaching one of the forum rules (written or unwritten).

Here are the other threads talking about this issue, I will tell you if one works, for the moment, I am still trying:

http://drupal.org/node/75413
http://drupal.org/node/85526

A module that might work:

http://drupal.org/node/59169

If anyone can share his experiences, I would be very thankful.

Have a nice day,

Felix.

felixsmile’s picture

I think the first of the previously posted threads can be very helpful. This is the code snippet mikegull had posted:

<?php
$vid = 5;    //vocab we're adding to
$parent = 1;   //parent tid
$terms = array(    //array of terms
'Ireland',
'Scotland',
'Wales',
'England'
); 

foreach ($terms as $term) {
   $edit = array ("vid" => $vid, "name" => $term, "parent"=>$parent );
   $msg = taxonomy_save_term($edit);
   print $edit['name'] . ": $msg<BR />\n";
}
?>

Now, I have two questions concerning this:

1) Can I add a description (and maybe even synonyms?) using this method? If yes, how?

2) How can I put apostrophes like this one ' in my terms (this is a php issue), I tried putting a / in front of them which didn't work.

Thank you very much in advance,

Felix.

felixsmile’s picture

Hello everyone,

Please let me know if I did not respect one of the points in the Netiquette.

Anyway, I've been looking more closely at the matter, and here is what I get:

I think these are the elements you need:
$edit["tid"] # leave blank to create a new term.
$edit["name"]
$edit["description"]
$edit["vid"] # id of vocab this term belongs to
$edit["weight"]
$edit["relations"] # array of tid's for related terms
$edit["parent"] # array of tid's that are parent terms
$edit["synonyms"] # array of strings that are the name of synonyms

Which i found here: http://drupal.org/node/8533.

Hope this helps, I can't think of anything better, please tell me if you know anything more effective.

Have a nice day,

Felix.

felixsmile’s picture

For the user import:

http://drupal.org/node/31940

For the taxonomy terms, a little script (to handle with care, especially for the descriptions and the size of the array, I didn't bother to add some security to it):

<?php
$vid = 5;    //vocab we're adding to
$parent = 8;   //parent tid
$terms = array(    //array of terms
'Term 1',
'Term 2'
);

$descr = array(    //array of terms
'Description 1',
'Description 2'
);

$i = 0;
foreach ($terms as $term) {
$edit = array ("vid" => $vid, "name" => $term, "parent"=>$parent, "description"=>$descr[$i++] );
$msg = taxonomy_save_term($edit);
print $edit['name'] . ": $msg<BR />\n";
};
?>

Have a nice day,

Felix.