0

I have a cck field in a node. I bring this value out in some other form and alter its value, But i am unable to save it back to DB. How should i write it back to table such that node changed date also gets changed. please show some code for this.

1

You can use node_save() to do this; CCK will automatically hook into it and update the field values in the database for you:

// Load a node
$node = node_load(1);

// Update the field value
$node->field_field_name = array(0 => array('value' => 'A value'));

// Save the node. Field values are also saved, and the node modified time is updated.
node_save($node);
0

You should try with hook_nodeapi(&$node, $op, ...) with $op='presave'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.