Is there a plan for an API to allow other modules to utilize this module to create node types:

Like having a callable function to be user in module installs:


/**
 * Implements hook_install().
 */
function examplemodule_install() {
  // create necessary CCK node types
  cck_import_type(drupal_get_path('module', 'examplemodule') .'/includes/cck_types/type1.cck');
  cck_import_type(drupal_get_path('module', 'examplemodule') .'/includes/cck_types/type2.cck');
  cck_import_type(drupal_get_path('module', 'examplemodule') .'/includes/cck_types/type3.cck');
}

I have a number of custom modules that would benefit greatly by this.

CommentFileSizeAuthor
#2 cck_import-636344.patch2.95 KBjrglasgow

Comments

jrglasgow’s picture

I added this to cck_import_custom.module.

I haven't tested it yet, but I will after my next meeting.

/**
 * Allow other modules to import cck node types
 */
function cck_import_custom_type($file_name) {
  $export_data = file_get_contents($file->filename);

  $form_state = array();
  $form_state['values']['type_name'] = '<create>';
  $form_state['values']['macro'] = $export_data;
  drupal_execute('content_copy_import_form', $form_state);
}
jrglasgow’s picture

Status: Active » Needs review
StatusFileSize
new2.95 KB

Here is a patch for this issue:

I tested it using a test module to install a cck node type. This is the install function that I used in my test module

function test_install() {
  require_once(drupal_get_path('module', 'cck_import_custom') .'/cck_import_custom.module');
  cck_import_custom_type(drupal_get_path('module', 'test') .'/test.type.cck');
}

psynaptic’s picture

This looks good. Sorry for not getting back to you sooner.

Would you like to be co-maintainer?