Needs review
Project:
Node import
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Jun 2009 at 23:24 UTC
Updated:
15 Jun 2009 at 23:24 UTC
I was quite suprised that no one had posted ANY issues about support for Node Hierarchy.
Well, I decided to make a quick solution and make my own add-on.
I didn't read any documentation but checked out some other support modules. So this might not be the cleanest version.
Just make your own nodehierarchy.inc -file in the supported -folder and then post the following code in it.
/**
* @file
* Support file for the nodehierarchy module.
*/
/**
* Implementation of hook_node_import_fields_alter().
*/
function nodehierarchy_node_import_fields($type) {
$fields = array();
$fields['parent'] = array(
'title' => t('Parent'),
'module' => 'nodehierarchy',
);
return $fields;
}
/**
* Implementation of hook_node_import_values_alter().
*/
function nodehierarchy_node_import_values_alter(&$values, $type, $fields){
$result = db_query('SELECT nid FROM {node} WHERE title = "%s"', $values['parent']);
if($row = db_fetch_array($result)) {
$values['parent'] = $row['nid'];
}
}
This code takes in ONLY the parent's title and then converts it to the node id. So the next step should be checking if the user has given a nid or the title and then do the thing.