CCK Import During Install

We've blogged about hardcore Drupal Form Manipulations using CCK Node Types and hooks. If it is part of your module (as it should) you need to install CCK type during module setup. In the .install file of that module you can import CCK definition with a code like:

function ourmodule_CCK_install() {

	$modulepath = drupal_get_path ('module', 'ourmodule');	
	$cck_definition_file = $modulepath."/custom.cck";

  $values['type_name'] = '<create>';
  $values['macro'] = file_get_contents($cck_definition_file);
  
  include_once( drupal_get_path('module', 'node') .'/content_types.inc');
  include_once( drupal_get_path('module', 'content') .'/content_admin.inc');
  
  drupal_execute("content_copy_import_form", $values); 
}

where custom.cck under your module folder is the file that you can export from CCK if you have cck_content_copy module installed.

Reply

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha Image: you will need to recognize the text in it.
Please type in the letters/numbers that are shown in the image above.