Posted by z3cka on March 18, 2009 at 8:39am
node.save
I had a very tough time finding what arguments were required by node.save... I finally guessed that a new node needed a "created" timestamp argument. Where should I post the following?
For new node creation be sure to set the creation time of the node:
var my_date:Date = new Date();
nodeObject.created = my_date.getTime();
and for editing existing nodes, be sure to set the changed time of the node:
var my_date:Date = new Date();
nodeObject.changed = my_date.getTime()
drupal 6 will complain if these arguments are not supplied. I used a simple if statement to handle both:
public function nodeSave():void{
var nodeObject:Object = new Object();
var my_date:Date = new Date();
nodeObject.type = "page";
nodeObject.nid = nid.text; // set to zero to create new node
nodeObject.title = title.text;
nodeObject.body = body.text;
if (nodeObject.nid == 0) {
nodeObject.created = my_date.getTime();
} else {
nodeObject.changed = my_date.getTime();
}
node.save(nodeObject);
}
If the NID is 0, then a new node will be created. Hope this helps, I didn't know where else to post this. Any feedback would be greatly appreciated.
Thanks,
-Casey
Comments
Your post is greatly
Your post is greatly appreciated over here :)
I cant get it to work
I am having a hard time saving a node because of nodeObject.created field, i am using D6 and Flex 3 AMFPHP
public function saveNode():void{
node.save(nodeObject);
when is used the node.submit there was an error message saying node.submit does not exist
How do we rattle this?