private function createVocab() { $vocabulary = array('name' => t('Blog categories'), 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'taxonomy', 'weight' => 0, 'tags' => 1, 'nodes' => array('blog' => 1)); taxonomy_save_vocabulary($vocabulary); $this->vid = $vocabulary['vid']; }
/** * lms_create_vocabulary create a Vocabulary by the givn parameters. * If a content type is provided, it will be associated with the vocabulary, * as a taxonomy node. * * @param mixed $vocab_name name of the vocabulary to be created * @param mixed $vocab_content_type content type to be associated with the vocabulary. * @param mixed $content_types content types enabled with the vocabulary. * @return vocabulary created */ function lms_create_vocabulary($vocab_name, $vocab_desc, $vocab_content_type = NULL, $content_types = NULL) { // 0. delete existing vocabulary if exists taxonomy_del_vocabulary($vocab_name); // content types which will use this vocabulary. $node_types = array(); if ($content_types) { foreach ($content_types as $content_type){ $node_types[$content_type] = 1; } } $vocab = array( 'name' => $vocab_name, 'description' => $vocab_desc, // 'help' => t('Help text'), 'nodes' => $node_types, 'hierarchy' => 1, 'relations' => 0, 'tags' => 0, 'multiple' => 1, 'required' => 0, 'weight' => 0, ); taxonomy_save_vocabulary($vocab); $vid = $vocab['vid']; // if the content type is provided, associate it with the vocab. if ($vocab_content_type) { taxonomynode_config_content_type($vid, $vocab_content_type); } return $vocab; }
/** * (non-PHPdoc) * @see Yamm_EntityAbstract::_update() */ protected function _update($vocabulary, $vid) { $edit = (array) $vocabulary; $edit['vid'] = (int) $vid; taxonomy_save_vocabulary($edit); }