DrupalでTaxonomyのVocabularyとTermを作成するコード。
$vocabulary = array( 'name' => 'Tags', 'description' => 'My Tags', 'help' => '', 'nodes' => array('story'=>1), // 対象ノードタイプの指定 'multiple' => 1, // 複数選択ON 'required' => 0, // 必須OFF 'hierarchy' => 0, // 階層OFF 'relations' => 0, // 関連TermOFF 'tags' => 1, // タグON 'module' => 'taxonomy', 'weight' => -1, // Weightを-1で指定 ); taxonomy_save_vocabulary($vocabulary); $terms = array('tag1','tag2','tag3'); $vid = $vocabulary['vid']; foreach($terms as $term){ $edit = array('vid'=>$vid, 'name'=>$term); taxonomy_save_term($edit); };