Arere? I could've sworn there was a module for this, but I can't find one in the module downloads for 4.7 or 4.6 and searches don't bring up much.

Right now I am using free tagging for Anime Series, but free tagging seems to have an invisible limit on how many terms you can input, so I want to change over to a standard multi-select. This will require a mass import of terms, all of the same level though... Any ideas?

Anisa.

Comments

mo6’s picture

Have a look at the devel module, it includes several snippets for creating/importing data into Drupal. Here is an example taxonomy-import code, taken from this module:

// written by Moshe Weitzman - weitzman at tejasa.com - July 2003

// BEWARE! this script adds data to your database

// -------------------------
// CONFIGURATION

    // Change the value below to TRUE when you want to run the script After running, immediately
    // change back to FALSE in order to prevent accidentally executing this script twice.
    $active = FALSE;

    // Enter the vocabulary ID into which you want to insert terms
    $vid = 88;

    // create an array of term names. order doesn't
    // matter since Drupal will present them alphabetically
    $terms = array (
      "Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","I
owa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New
Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","
South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming","Washington D.C."
    );
// -------------------------
// CODE

    include_once "includes/bootstrap.inc";
    include_once("includes/common.inc");

    if ($active) {
      if (user_access("administer taxonomy")) {
        foreach ($terms as $term) {
          $edit = array ("vid" => $vid, "name" => $term );
          $msg = taxonomy_save_term($edit);
          print $msg;
        }
      }
      else {
        print "You have insufficent permission to  administer taxonomy";
      }
    }
    else {
      print "You have not activated term_loader. See $active variable at top of the source code";
    }
mo6’s picture

You'd probably have to modify the includes in the above code to:

  include_once './includes/bootstrap.inc';
  drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

to make it work properly in a recent Drupal version.

mikegull’s picture

If you have the "devel" block with the "execute PHP code snippet" menu item turned on, you can do something like:

$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";
}
Muslim guy’s picture

Is there something wrong with db.module for Drupal 4.7.3

I was trying to import 72 terms into a Vocabulary - it is crazy to do it manually, since the terms were from a sister site and we want to have a backup site with the same categories

The SQL is like this:
--------------------------------------------------------------------------
-- Drupal dba.module database dump
--
-- Database: ****_****
-- Date: Thursday, 28 September 2006 - 8:38pm

--
-- Table structure for table 'term_data'
--

DROP TABLE IF EXISTS term_data;
CREATE TABLE term_data (
tid int(10) unsigned NOT NULL auto_increment,
vid int(10) unsigned NOT NULL default '0',
name varchar(255) NOT NULL default '',
description longtext default NULL,
weight tinyint(4) NOT NULL default '0',
PRIMARY KEY (tid),
KEY vid (vid)
) TYPE=MyISAM;

--
-- Dumping data for table 'term_data'
--

INSERT INTO term_data VALUES("3","2","Produk Usahawan","","-9");
INSERT INTO term_data VALUES("4","2","Servis dan Perkhidmatan Usahawan","","-8");
INSERT INTO term_data VALUES("5","2","Berita dan artikel","","10");
INSERT INTO term_data VALUES("11","2","Makanan","","0");

and so on until the last is
INSERT INTO term_data VALUES("72","2","Stuff","","0");

---------------------------------------------------------------------------

But when we checked the Vocabulary (the ID 2 is for IMAGE gallery) there is none!

We also tried dropping the tables and use PHPmyAdmin instead. From term_data.sql backed up using dba.module, we click `Import' and upload term_data.sql succesfully.

But whats the reason the `LIst Term' for our IMAGE is still nothing?

Is it incorrect because the ID 2 inside the INSERT INTO term_data VALUES("72","2" is not pointing to

admin/taxonomy/edit/vocabulary/2 where it was supposed to go into?

aaronschachter’s picture

add a record into term_hierarchy for each new record in term_data and they'll show up.