You are here

function _taxonomy_vocabulary_resource_create in Services 7.3

Same name and namespace in other branches
  1. 6.3 resources/taxonomy_resource.inc \_taxonomy_vocabulary_resource_create()

Create a new taxonomy vocabulary based on submitted values.

Here is a sample vocabulary array, taken from http://drupaldeveloper.in/article/programmatically-create-vocabulary


$vocabulary = array(
  'name'  => t("Name"). // Human readable name of the vocabulary
  'description' => t("Description"), // extended description of the vocabulary
  'help' => t("help"), // help text
  'tags' => 0, // 1 to make this vocabulary free tagging
  'multiple' => 0, // 1 to allow multiple selection
  'required' => 0, // 1 to make the terms mandatory to be selected
  'hierarchy' => 0, // 1 to allow and create hierarchy of the terms within the vocabulary
  'relations' => 0, // 1 to set and allow relation amongst multiple terms
  'module' => 'mymodule', // provide the module name in which the vocabulary is defined and which is calling this function
  'node' => array('story' => 1), // content types to which this vocabulary will be attached to
  'weight' => -9, // set the weight to display the vocabulary in the list
);

Parameters

$vocabulary: Array of values for the taxonomy vocabulary.

Return value

Status constant indicating if vocabulary was inserted or updated.

See also

taxonomy_vocabulary_save()

1 string reference to '_taxonomy_vocabulary_resource_create'
_taxonomy_resource_definition in resources/taxonomy_resource.inc
@file Link general taxonomy functionalities to services module.

File

resources/taxonomy_resource.inc, line 478
Link general taxonomy functionalities to services module.

Code

function _taxonomy_vocabulary_resource_create($vocabulary) {

  // Adds backwards compatability with regression fixed in #1083242
  $vocabulary = _services_arg_value($vocabulary, 'vocabulary');
  $vocabulary = (object) $vocabulary;
  return taxonomy_vocabulary_save($vocabulary);
}