You are here

function biblio_add_fields in Bibliography Module 7.2

Adds Biblio's fields (not field instances) to Drupal's Field API This function runs upon enabling Biblio @todo Add biblio.field.type.data.csv data (field instance labels, etc)

1 call to biblio_add_fields()
biblio_install in ./biblio.install
Implements hook_install().

File

includes/biblio.fields.inc, line 24

Code

function biblio_add_fields() {
  $file = drupal_get_path('module', 'biblio') . '/misc/default_fields.json';
  $json = json_decode(file_get_contents($file), TRUE);
  foreach ($json as $field) {
    $field_exists = field_info_field($field['field_name']) ? TRUE : FALSE;
    if (!$field_exists) {
      field_create_field($field);
    }
  }
}