Hello.

Has anyone tried updating nodes programmatically in Drupal 5?
I'm particularly interested in how to reflect changes in the node body and be able to save them programmatically.

Thanks.
Pol

Comments

shyamala’s picture

Are you talking of a computed fields?? Can you elaborate your requirement?

Try using CCK and computed fields to have nodes updated programatically.

Shyamala
Team Leader Netlink Technologies Ltd.

palabat’s picture

What I want to do is to save the changes on the node object into the database programmatically.
The way I intend to do it is:
Load the node object using node_load($nid).
Modify the $node->body.
Save the modified $node object as if submitting values from the edit node form.

Please help if it can be done.

Thanks.

nevets’s picture

Given you have a node object you can do this

$node = node_submit($node);
node_save($node);
palabat’s picture

Thanks for your suggestion.
There must be a reason why I need to use node_submit method and not go directly to node_save.
Which method ensures that I'm not duplicating a node if a node of the same nid exists?

nevets’s picture

node_submit() does both some sanity checks, initializing of unset data and probably most importantly calls both the submit hook for the content type and any nodeapi hooks with an op of 'submit'. These actions make sure any data not related to the core definition of a node gets saved. Some examples would taxonomy terms and CCK fields.