Closed (fixed)
Project:
Node Comments
Version:
6.x-2.0-beta3
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Jun 2010 at 17:37 UTC
Updated:
19 Jun 2010 at 00:40 UTC
Hi,
I have a large set of data that I try to make accessible with an drupal installation.
I used the node import module to import two types of content types, where one is the basis and the other one should be attached to these base nodes via node comments. Every node comment content type has a field with the NID of its parent. There are no threads or anything fancy.
Now, how would I go ahead to attach the node comment cts to their appropriate parent? I guess it would be easiest to do this programmatically as I really have a rather big set of data.
Any help would be appreciated.
Andrej
Comments
Comment #1
crea commentedI can only recommend to look at the nodecomment_save() function which does most of the additional comment-related job.
Comment #2
andrej235 commentedThis seems to be the way to go. However, I can't find out how to use the function on the already existing nodes. More specifically, what is the structure the node argument must have?
Comment #3
andrej235 commentedSo here a short template how to do it. Correct me if it is wrong.
I am not sure what to do with the thread part. Maybe some illumination on it?
$node_type = 'node_type_name';
$result = db_query("SELECT nid FROM {node} WHERE type='%s'",$node_type);
while ($row = db_fetch_object($result)){
$node = node_load($row->nid);
$target = $node->field_nid[0]['value'];
$node->comment_target_nid = $target;
$node->comment_target_cid = 0 ;
nodecomment_save($node);
}