Helper function to create a content type


/ Published in: PHP
Save to your folder(s)

With thanks to emspace for the original code :)


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.