Return to Snippet

Revision: 3988
at October 14, 2007 11:40 by WimLeers


Updated Code
/**
 * Helper function to import a CCK content type definition from a text file.
 *
 * @param $cck_definition_file
 *   The full path to the file containing the CCK definition.
 */
function _create_content_type($cck_definition_file) {
  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
  include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
  $values = array();
  $values['type_name'] = '<create>';
  $values['macro'] = file_get_contents($cck_definition_file);
  drupal_execute("content_copy_import_form", $values);
}

Revision: 3987
at October 14, 2007 11:39 by WimLeers


Updated Code
/**
 * Helper function to import a CCK content type definition from a text file.
 *
 * @param $cck_definition_file
 *   The full path to the file containing the CCK definition.
 */
function _create_content_type($cck_definition_file) {
  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
  include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
  $values = array();
  $values['type_name'] ='<create>';
  $values['macro'] = file_get_contents($cck_definition_file);
  drupal_execute("content_copy_import_form", $values);
}

Revision: 3986
at October 14, 2007 11:39 by WimLeers


Initial Code
/**
 * Helper function to import a CCK content type definition from a text file.
 *
 * @param $cck_definition_file
 *   The full path to the file containing the CCK definition.
 */
function _create_content_type($cck_definition_file) {
  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
  include_once('./'. drupal_get_path('module', 'content') .'/content_admin.inc');
  $values = array();
  $values['type_name'] ='<create>';
  $values['macro'] = file_get_contents($cck_definition_file);
  drupal_execute("content_copy_import_form", $values);
}

Initial URL
http://groups.drupal.org/node/5272

Initial Description
With thanks to joshk :)

Initial Title
Import CCK definition from text file

Initial Tags
textmate, drupal

Initial Language
PHP