Reproduction.
-Create a CCK node called domain
-Create a new module - mymodule
-Create the hook-nodeapi as follows
function mymodule_nodeapi(&$node, $op, $teaser = NULL, $page = NULL)
{
if ($node->type == 'domain')
{
switch ($op)
{
case 'insert':
case 'update':
$domain = preg_replace("/^http:\/\//i", "", trim($node->title));
$node->title = preg_replace("/^www./i", "", $domain);
break;
}
}
}
Edit the node and enter http://www.abc.com as the title and save the node.
The message shows that abc.com has been saved however http://www.abc.com is actually saved.
I havde assumed that the node changes are meant to be allowed since the node is passed in by reference otherwise it would seem senseless to pass the node in that way.
Thanks,
KT
Comments
Comment #1
yched commentedCCK does not handle this. Note that there are no such things as 'CCK nodes'. CCK is only responsible for fields it 'adds' to nodes, not for nodes themselves
Comment #2
damien tournoud commentedAnd there is a marvelous documentation for hook_nodeapi(): you can't modify the content of the node during insert and update operations. You are perhaps looking for the 'presave' operation, or, better yet, adding a '#validate' handler to the node form.
Comment #3
ktalai commentedThank you very much for the guidance