Created
January 27, 2011 22:11
-
-
Save cyberswat/799394 to your computer and use it in GitHub Desktop.
hook_install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_install(). | |
*/ | |
function complex_widget_install() { | |
// Create the content type using node_content as the base. | |
$t = get_t(); | |
$node_type = array( | |
'type' => 'my_node_type', | |
'name' => $t('Complex widget example'), | |
'base' => 'node_content', | |
'description' => $t('A simple node that illustrates a complex field and widget'), | |
); | |
// Set content type defaults and save the new content type. | |
$content_type = node_type_set_defaults($node_type); | |
node_type_save($content_type); | |
// Create all the fields we are adding to our content type. | |
// http://api.drupal.org/api/function/field_create_field/7 | |
foreach (_complex_widget_installed_fields() as $field) { | |
field_create_field($field); | |
} | |
// Create all the instances for our fields. | |
// http://api.drupal.org/api/function/field_create_instance/7 | |
foreach (_complex_widget_installed_instances() as $instance) { | |
$instance['entity_type'] = 'node'; | |
$instance['bundle'] = $node_type['type']; | |
field_create_instance($instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment