Posted by joegml on October 10, 2008 at 5:49pm
Anybody have any good references on this? I've looked at http://www.civicactions.com/blog/cck_import_and_update and like Wim Leers approach in that post of using files for CCK type imports: seems clean and modular, only problem is it doesn't work for me ;-) ARGH ^&*
I've googled about a bit and found a bunch of refs to "Programatic CCK Install" but I think most of these refer to D5. I'm not getting errors on install and I can do the CCK import smoothly by copying and pasting into the textarea w/ admin/content/types/import, but the code below does NOT install the CCK type.
Any guidance appreciated. Thanks.
// hook_install
function pegevent_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
_create_content_type( pegevent-program-definition.txt );
break;
case 'pgsql':
drupal_set_message('PostgresSQL not supported', 'error');
break;
}
}
// hook_update_N
/**
* 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.
*/
// From Wim Leers http://www.civicactions.com/blog/cck_import_and_update
function _create_content_type($cck_definition_file) {
# JG Hack
include_once('/var/www/modules/node/content_types.inc');
include_once('/var/www/sites/all/modules/cck/includes/content.admin.inc');
$values = array();
$values['type_name'] = '<create>';
$values['macro'] = file_get_contents($cck_definition_file);
drupal_execute("content_copy_import_form", $values);
}
Comments
I recently started using
I recently started using install_profile_api module. See http://drupal.org/node/310823