I am trying to create an entity definition that represents a new content type that I added ('initiative') which has a variety of cck fields (e.g. 'stage', 'award', etc.)
After creating the new 'initiative' content type, it automatically appeared on my ui list of entities to export (import); however the cck fields did not.
I thought I could simply create my own 'initiative' definition to include these fields. I modeled the definition more or less on the importexportapi_book.inc file.
The code is below, any guidance would be greatly appreciated.
function initiative_def() {
$defs = array();
$type = 'initiative';
$def = importexportapi_node_get_def($type); //this should pull in all the basic node info
$def['#title'] = 'initiative';
$def['#title'][0] = strtoupper($def['#title'][0]);
$def['#xml_plural'] = $def['#csv_plural'] = 'initiatives';
$def['revisions']['#csv_plural'] = 'initiative-revisions';
$def['type']['#db_filter'] = array(
'values' => array($type) // this should filter the basic node info by the custom 'initiative' type
);
$def['revisions']['initiative_vid'] = array(
'#type' => 'int',
'#title' => t('Initiative Revision ID'),
'#reference_entity' => $type,
'#reference_field' => array('vid'),
'#db_table' => 'content_type_initiative',
'#db_field_unaliased' => 'vid',
'#key_component' => TRUE,
'#csv_hidden' => TRUE
);
$def['revisions']['initiative_nid'] = array(
'#type' => 'int',
'#title' => t('Initiative Node ID'),
'#reference_entity' => $type,
'#reference_field' => array('nid'),
'#db_table' => 'content_type_initiative',
'#db_field_unaliased' => 'nid',
'#csv_hidden' => TRUE
);
$def['revisions']['initiative_stage'] = array (
'#type' => 'string',
'#title' => t('initiative stage'),
'#reference_entity' => $type,
'#db_table' => 'content_type_initiative',
'#db_field_unaliased' => 'field_stage_value'
);
$def['revisions']['initiative_award'] = array (
'#type' => 'string',
'#title' => t('initiative award'),
'#reference_entity' => $type,
'#db_table' => 'content_type_initiative',
'#db_field_unaliased' => 'field_stage_award'
);
$defs['initiave'] = $def;
return $defs;
}
/**
* Implementation of hook_db_def_tables().
*/
function initiative_db_def_tables() {
$tables = array();
$tables['content_type_initiative'] = 'cti';
return $tables;
}
Comments
Comment #1
romca commentedI expected the same, created just a new content type for a testing purposes, with two cck fields, non of them is in the export, the wiki is full of spam so that the announced help is not accessible, seems that one needs to dig into the source code, wait for new FAPI in drupal 6 or use another import module.
Cheers,
roman
Comment #2
sunTo quote Jaza, the original author of this API: