Return to Snippet

Revision: 3982
at October 14, 2007 10:46 by WimLeers


Updated Code
/**
 * Helper function to create a content type.
 *
 * @param $properties
 *   An array with node type properties, that override the default ones.
 */
function _create_content_type($properties) {
  $default = array(
    'type' => '',
    'name' => t(''),
    'module' => 'node',
    'description' => t(''),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );

  $type = array_merge($default, $properties);
  $type = (object) _node_type_set_defaults($type);
  node_type_save($type);
}

Revision: 3981
at October 14, 2007 08:06 by WimLeers


Updated Code
/**
 * Helper function to create a content type.
 *
 * @params $properties
 *   An array with node type properties, that override the default ones.
 */
function _create_content_type($properties) {
  $default = array(
    'type' => '',
    'name' => t(''),
    'module' => 'node',
    'description' => t(''),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );

  $type = array_merge($default, $properties);
  $type = (object)_node_type_set_defaults($type);
  node_type_save($type);
}

Revision: 3980
at October 14, 2007 07:12 by WimLeers


Updated Code
function _create_content_type($properties) {
  $default = array(
    'type' => '',
    'name' => t(''),
    'module' => 'node',
    'description' => t(''),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );

  $type = array_merge($default, $properties);
  $type = (object)_node_type_set_defaults($type);
  node_type_save($type);
}

Revision: 3979
at October 14, 2007 07:10 by WimLeers


Initial Code
function _create_content_type($properties) {
  $default = array(
    'type' => '',
    'name' => t(''),
    'module' => 'node',
    'description' => t(''),
    'custom' => TRUE,
    'modified' => TRUE,
    'locked' => FALSE,
  );

  $type = array_merge($default, $properties);
  $type = (object)_node_type_set_defaults($type);
  node_type_save($type);
}

Initial URL

                                

Initial Description
With thanks to emspace for the original code :)

Initial Title
Helper function to create a content type

Initial Tags
textmate, drupal

Initial Language
PHP