I am trying to create the following functionality:
When a user tries to create a node, he is not allowed to create the node if another node with the field value he is trying to enter exists. Instead, the original node will be 'voted up' using some implementation of voting api. Let's say this field contains a toy. So people aren't allowed to submit a node recommending a particular toy if this toy already exists - if they tried to this, the node that was originally created for the toy will receive that user's vote. This will of course avoid duplicates etc.
I'm having trouble with the code, which I guess should look something like this:
/**
* Implementation of hook_validate().
*/
function mymod_validate($node) {
if (isset($node->toy) && [something that checks to see whether this value already exists]) {
$type = node_get_types('type', $node);
[something which grabs the id of the original node from two lines above, and votes it up with votingapi];
form_set_error('toy', t('The toy you have tried to recommend already exists, so your vote has been cast in favour of the original submission.'));
}
}
Can anyone give me any help with this, please? Any help much appreciated.
Comments
Use NodeAPI
I think you may have better success with hook_nodeapi
http://api.drupal.org/api/function/hook_nodeapi
---------------------------------
Steven Wright
Slalom