Created
March 16, 2012 23:47
-
-
Save vincenzo/2053654 to your computer and use it in GitHub Desktop.
Programmatic CCK Content Type - Step 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function _example_cck_content_save_cck_node($op = 'install') { | |
module_load_include('inc', 'example_cck_content', 'example_cck_content.def'); | |
$content = _example_cck_content_cck_export(); | |
// we do not want too many modules enabled - the content_copy module is just needed | |
// in order to install the content type, so we just require it here (require_once prevent to | |
// include it more than once in case it is already enabled) | |
require_once './' . drupal_get_path('module', 'content') . '/modules/content_copy/content_copy.module'; | |
if ($op == 'install') { | |
$form_state['values']['type_name'] = '<create>'; | |
} | |
else { | |
// the type_name must be the type_name | |
// as specified in the .def.inc file | |
$form_state['values']['type_name'] = 'example_cck_content'; | |
} | |
$form_state['values']['macro'] = '$content = ' . var_export($content, TRUE) . ';'; | |
drupal_execute('content_copy_import_form', $form_state); | |
content_clear_type_cache(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment