function newsletter_fields_instances in Newsletter 7
2 calls to newsletter_fields_instances()
- newsletter_install in ./
newsletter.install - Implements hook_install().
- newsletter_uninstall in ./
newsletter.install - Implements hook_uninstall().
File
- ./
newsletter.install, line 367 - Contains install,uninstall and update functions for Newsletter module.
Code
function newsletter_fields_instances() {
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
// Field names have 32 char limit.
$field_name = 'field_' . substr($vocabulary->machine_name, 0, 26);
$fields[] = 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 ($vocabulary->machine_name == 'newsletter_categories') {
$instances[] = array(
'field_name' => 'field_newsletter_categories',
'entity_type' => 'newsletter_list',
'bundle' => 'newsletter_list',
'label' => 'Category',
'widget' => array(
'weight' => 0,
'type' => 'taxonomy_autocomplete',
),
);
}
else {
$instances[] = array(
'field_name' => $field_name,
'entity_type' => 'newsletter_template',
'bundle' => 'newsletter_template',
'label' => $vocabulary->name,
'widget' => array(
'weight' => 0,
'type' => 'options_select',
),
);
}
}
$fields[] = array(
'field_name' => 'field_newsletter_list',
'type' => 'entityreference',
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
'settings' => array(
'target_type' => 'newsletter_list',
'handler' => 'base',
'handler_submit' => 'Change handler',
'handler_settings' => array(
'target_bundles' => array(),
'sort' => array(
'type' => 'none',
),
),
),
);
$fields[] = array(
'field_name' => 'field_newsletter_template',
'type' => 'entityreference',
'settings' => array(
'target_type' => 'newsletter_template',
'handler' => 'base',
'handler_submit' => 'Change handler',
'handler_settings' => array(
'target_bundles' => array(),
'sort' => array(
'type' => 'none',
),
),
),
);
$fields[] = array(
'field_name' => 'field_list_description',
'type' => 'text',
);
$fields[] = array(
'field_name' => 'field_newsletter_body',
'type' => 'text_with_summary',
);
$instances[] = array(
'field_name' => 'field_list_description',
'entity_type' => 'newsletter_list',
'bundle' => 'newsletter_list',
'label' => 'Description',
'widget' => array(
'weight' => 0,
'type' => 'text_textfield',
),
);
$instances[] = array(
'field_name' => 'field_newsletter_list',
'entity_type' => 'newsletter_subscriber',
'bundle' => 'newsletter_subscriber',
'label' => 'Lists',
'required' => TRUE,
'widget' => array(
'weight' => 0,
'type' => 'options_buttons',
'active' => 1,
),
'settings' => array(
'target_type' => 'newsletter_list',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array(
'newsletter_list',
),
),
),
);
$instances[] = array(
'field_name' => 'field_newsletter_template',
'entity_type' => 'newsletter_list',
'bundle' => 'newsletter_list',
'label' => 'Template',
'required' => TRUE,
'widget' => array(
'weight' => 0,
'type' => 'options_select',
'active' => 1,
),
'settings' => array(
'target_type' => 'newsletter_template',
'handler' => 'base',
'handler_settings' => array(
'target_bundles' => array(
'newsletter_template',
),
),
),
);
$instances[] = array(
'field_name' => 'field_newsletter_body',
'entity_type' => 'newsletter_template',
'bundle' => 'newsletter_template',
'label' => 'Body',
'widget' => array(
'type' => 'text_textarea_with_summary',
),
'settings' => array(
'display_summary' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
),
),
);
$instances[] = array(
'field_name' => 'field_newsletter_body',
'entity_type' => 'newsletter_newsletter',
'bundle' => 'newsletter_newsletter',
'label' => 'Body',
'widget' => array(
'type' => 'text_textarea_with_summary',
),
'settings' => array(
'display_summary' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
),
),
);
return array(
'field' => $fields,
'instance' => $instances,
);
}