Index: taxonomy_csv.module =================================================================== --- taxonomy_csv.module (revision 213) +++ taxonomy_csv.module (working copy) @@ -8,6 +8,7 @@ define('TAXONOMY_CSV_IGNORE', 0); define('TAXONOMY_CSV_FIELDS', 1); define('TAXONOMY_CSV_CHILDREN', 2); +define('TAXONOMY_CSV_WEIGHTS', 3); /** * Implementation of hook_help(). @@ -74,6 +75,7 @@ TAXONOMY_CSV_IGNORE => t('Ignore'), TAXONOMY_CSV_FIELDS => t('Term description, term synonyms (may be empty)'), TAXONOMY_CSV_CHILDREN => t('Child term names'), + TAXONOMY_CSV_WEIGHTS => t('Term weights'), ), '#default_value' => TAXONOMY_CSV_IGNORE, '#description' => t('The first column is always imported as the term name. This option determines how additional columns will be imported. If your CSV file only contains one column, this option will be ignored.'), @@ -219,6 +221,16 @@ $parent = $term['tid']; } } + else if ($options['columns'] == TAXONOMY_CSV_WEIGHTS) { + if (count($line) > 1 && !empty($line[1])) { + $term = array( + 'name' => $line[0], + 'vid' => $options['vid'], + 'weight' => $line[1], + ); + taxonomy_csv_import_term($term, $options['update']); + } + } else if (!empty($line[0])) { $term = array( 'name' => $line[0], @@ -254,7 +266,7 @@ */ function taxonomy_csv_import_term($term, $update = TRUE) { if ($update && ($existing_term = taxonomy_csv_find_term($term['name'], $term['vid'], isset($term['parent']) ? $term['parent'] : NULL))) { - foreach (array('description', 'synonyms') as $key) { + foreach (array('description', 'synonyms', 'weight' ) as $key) { if (array_key_exists($key, $term)) $existing_term[$key] = $term[$key]; }