All pastes #736242 Raw Edit

create content type

public php v1 · immutable
·published 2007-10-14 11:01 UTC
rendered paste body
function _create_content_type($properties) {  $default = array(    'type' => '',    'name' => st(''),    'module' => 'node',    'description' => st(''),    'custom' => TRUE,    'modified' => TRUE,    'locked' => FALSE,  );  $type = array_merge($default, $properties);  $type = (object)_node_type_set_defaults($type);  node_type_save($type);}function _create_content_field($type_name, $properties) {  $default = array(    'label' => 'A field label', // <-- Set this on $properties    'field_widget_type' => '',  // <-- Set this on $properties, see list above.    'op' => 'Create field',    'submit' => 'Create field',    'locked' => FALSE,    'field_name' => '', // <-- Set this on $properties, lowercase underscore pls  );  $new_field = array_merge($default, $properties);  $new_field['type_name'] = $type_name;  _content_admin_field_add_new_submit('_content_admin_field_add_new', $new_field);}