You are here

function biblio_create_term_ref in Bibliography Module 7

1 call to biblio_create_term_ref()
biblio_insert_keywords in includes/biblio.keywords.inc
Insert keywords into the database.

File

includes/biblio.keywords.inc, line 485
Contains all keyword related functions.

Code

function biblio_create_term_ref($vocabulary) {
  $field_name = 'field_' . $vocabulary->machine_name . '_ref';
  $field = array(
    'field_name' => $field_name,
    'type' => 'taxonomy_term_reference',
    'cardinality' => FIELD_CARDINALITY_UNLIMITED,
    'settings' => array(
      'allowed_values' => array(
        array(
          'vocabulary' => $vocabulary->machine_name,
          'parent' => 0,
        ),
      ),
    ),
  );
  if (!field_info_field($field['field_name'])) {
    field_create_field($field);
  }
  $instance = array(
    'field_name' => $field_name,
    'entity_type' => 'node',
    'label' => $vocabulary->name,
    'bundle' => 'biblio',
    'required' => FALSE,
    'widget' => array(
      'type' => 'options_select',
      'cardinality' => -1,
    ),
    'display' => array(
      'default' => array(
        'type' => 'hidden',
      ),
      'teaser' => array(
        'type' => 'hidden',
      ),
    ),
  );
  field_create_instance($instance);
}