Posted By

WimLeers on 10/14/07


Tagged

textmate drupal cck


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

WimLeers
basicmagic
kellyharding
heinz1959


Helper function to create a content type


 / Published in: PHP
 

With thanks to emspace for the original code :)

  1. /**
  2.  * Helper function to create a content type.
  3.  *
  4.  * @param $properties
  5.  * An array with node type properties, that override the default ones.
  6.  */
  7. function _create_content_type($properties) {
  8. $default = array(
  9. 'type' => '',
  10. 'name' => t(''),
  11. 'module' => 'node',
  12. 'description' => t(''),
  13. 'custom' => TRUE,
  14. 'modified' => TRUE,
  15. 'locked' => FALSE,
  16. );
  17.  
  18. $type = array_merge($default, $properties);
  19. $type = (object) _node_type_set_defaults($type);
  20. node_type_save($type);
  21. }

Report this snippet  

You need to login to post a comment.