function node_reference_import_alter in Default Content 7
Same name and namespace in other branches
- 7.2 plugins/node_reference.inc \node_reference_import_alter()
Handles the importing of node_reference fields
Change the machine_name of ref nodes to there nid
File
- plugins/
node_reference.inc, line 45
Code
function node_reference_import_alter(&$node) {
$fields = get_ref_fields();
foreach ($fields as $field_name => $field) {
if (isset($node->{$field_name})) {
foreach ($node->{$field_name} as $lang => $items) {
foreach ($items as $key => $item) {
if (($machine_name = $item['machine_name']) && ($nid = defaultcontent_get_default($machine_name))) {
$node->{$field_name}[$lang][$key]['nid'] = $nid;
unset($node->{$field_name}[$lang][$key]['machine_name']);
}
elseif (isset($item['nid'])) {
//TODO remove
}
else {
unset($node->{$field_name}[$lang][$key]);
}
}
}
}
}
}