function rdf_example_install

Implements hook_install().

  • Create photo, summary fields.
  • Create photo, summary instances.

See also

node_type_set_defaults()

field_info_instance()

field_update_instance()

field_create_field()

field_create_instance()

Related topics

File

rdf_example/rdf_example.install, line 24

Code

function rdf_example_install() {
    // Use get_t() to get the name of our localization function for translation
    // during install, when t() is not available.
    $t = get_t();
    // Define the node type.
    $rdf_example = array(
        'type' => 'recipe',
        'name' => $t('Recipe'),
        'base' => 'node_content',
        'description' => $t('The recipe node is defined to demonstrate RDF mapping.'),
    );
    // Set additional defaults and save the content type.
    $content_type = node_type_set_defaults($rdf_example);
    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 (_rdf_example_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 (_rdf_example_installed_instances() as $instance) {
        $instance['entity_type'] = 'node';
        $instance['bundle'] = $rdf_example['type'];
        field_create_instance($instance);
    }
}