| 34 |
foreach ($content_type->fields as $field) { |
foreach ($content_type->fields as $field) { |
| 35 |
if (strpos($field['widget']['type'], 'nodereference') === 0) {//nodereference node: query nid of the referenced node |
if (strpos($field['widget']['type'], 'nodereference') === 0) {//nodereference node: query nid of the referenced node |
| 36 |
$referenced_nodes = array(); |
$referenced_nodes = array(); |
| 37 |
$sql = "select title from {node} where title sounds like '%s'"; |
$sql = "select nid, title from {node} where title sounds like '%s'"; |
| 38 |
$result = db_query($sql, $node->$field['field_name']); |
$result = db_query($sql, $node->$field['field_name']); |
| 39 |
$record_found = db_fetch_object($result); |
$record_found = db_fetch_object($result); |
| 40 |
|
|
| 41 |
if ($record_found) { |
if ($record_found) { |
|
|
|
| 42 |
if ($field['multiple']) { |
if ($field['multiple']) { |
| 43 |
$node->$field['field_name'] = array('title' => array(0 => $record_found->title)); |
$node_field = array(0 => array('nid' => $record_found->nid)); |
| 44 |
} else { |
} else { |
| 45 |
$node->$field['field_name'] = array('title' => $record_found->title); |
$node_field = array('nid' => $record_found->nid); |
| 46 |
} |
} |
|
//update the node field with proper info (nid(s) of referenced nodes) |
|
|
nodereference_widget('submit', $node, $field); |
|
| 47 |
} else { |
} else { |
| 48 |
$node->$field['field_name'] = array(); |
$node_field = array(); |
| 49 |
} |
} |
| 50 |
|
$node->$field['field_name'] = $node_field; |
| 51 |
|
|
| 52 |
} else {//default node types: add value to array w/ key 'value' |
} else {//default node types: add value to array w/ key 'value' |
| 53 |
$thisval = $node->$field['field_name']; |
$thisval = $node->$field['field_name']; |