Posted by Ghostthinker on March 12, 2010 at 11:31pm
Hi,
I want to alter the value of a cck (file) field. But the Problem is, that the field gets lost upon save.
- I set the field right, the debug($node) function displays the node is it should be
- the function works. when I do a node_load - myfunction - node_save, everything works, field is saved
So why does my setup not work? Is there something about module weights, nodeapi execution order, etc that I forgot about?
/**
* Implementation of hook_nodeapi().
*
* @author: me
*/
function mymodule_nodeapi(&$node, $op) {
//we only care about mytype
if ($node->type != 'mytype')
return;
switch ($op) {
case "insert":
case "submit":
alter_my_field_by_reference($node);
debug($node);
}
}
function alter_my_field_by_reference(&$node){
...
}Thank you
Comments
Hi, yes, I am quite sure it
Hi,
yes, I am quite sure it is about the weight of the modules. If your module just alters the node that is being saved, it is possible that the cck module has already saved the node before you had the chance to alter it. So, in this case, you should try to change the weight of the module from the "system" table to be smaller than the weight of the cck modules (that is usually 0...)
Vasi.
Great, thank you. I just
Great, thank you. I just tried to increase weight.