You are here

function date_tools_wizard_create_content_type in Date 7.2

Same name and namespace in other branches
  1. 8 date_tools/date_tools.wizard.inc \date_tools_wizard_create_content_type()
  2. 6.2 date_tools/date_tools.wizard.inc \date_tools_wizard_create_content_type()
  3. 7.3 date_tools/date_tools.wizard.inc \date_tools_wizard_create_content_type()
  4. 7 date_tools/date_tools.wizard.inc \date_tools_wizard_create_content_type()

Create date tools wizard content type.

1 call to date_tools_wizard_create_content_type()
date_tools_wizard_build in date_tools/date_tools.wizard.inc
Wizard build.

File

date_tools/date_tools.wizard.inc, line 348
The Date Wizard code.

Code

function date_tools_wizard_create_content_type($name, $bundle, $description, $type_settings = array()) {
  date_tools_wizard_include();

  // Create the content type.
  $values = array(
    'name' => $name,
    'type' => $bundle,
    'description' => $description,
    'title_label' => 'Title',
    'body_label' => 'Body',
    'min_word_count' => '0',
    'help' => '',
    'node_options' => array(
      'status' => 1,
      'promote' => 1,
      'sticky' => 0,
      'revision' => 0,
    ),
    'language_content_type' => '0',
    'old_type' => $bundle,
    'orig_type' => '',
    'base' => 'node_content',
    'custom' => '1',
    'modified' => '1',
    'locked' => '0',
    'url_str' => str_replace('_', '-', $bundle),
  );

  // Allow overrides of these values.
  foreach ($type_settings as $key => $value) {
    $values[$key] = $value;
  }
  node_type_save((object) $values);

  // Add the body field.
  $trim_length = variable_get('teaser_length', 600);
  $field = field_info_field('body');
  $instance = array(
    'field_name' => 'body',
    'entity_type' => 'node',
    'bundle' => $bundle,
    'label' => t('Description'),
    'widget' => array(
      'type' => 'text_textarea_with_summary',
      'settings' => array(
        'rows' => 20,
        'summary_rows' => 5,
      ),
      'weight' => -4,
      'module' => 'text',
    ),
    'settings' => array(
      'display_summary' => TRUE,
    ),
    'display' => array(
      'default' => array(
        'label' => 'hidden',
        'type' => 'text_default',
      ),
      'teaser' => array(
        'label' => 'hidden',
        'type' => 'text_summary_or_trimmed',
        'trim_length' => $trim_length,
      ),
    ),
  );
  field_create_instance($instance);
}