Hi
I am creating nodes programmatically and giving titles to nodes indiviually, however it's causing duplicates the module can't see.
$node = new stdClass();
$node->uid = 1;
$node->type = 'page';
$node->title = 'Unique title' . '$user_profile_common_keyword' . ' no more with this title, please';
node_save($node);
How should I relate a string with the node title?
if ($my_string_title != $node->title){
}
else {
}
I don't know how to relate the nids.
Is there a function or hook In the module? I had a look at the code and couldn't get it.
With Regards
Jorge.
Comments
Comment #1
carlovdb commentedDoes anyone has a solution?
Comment #2
oryx commentedIt took me quite some time to figure this out, but you can use the unique_field_match_value() function to programatically check that your value is not already stored in a unique field. If the field value already exists, the function returns an array containing the nid the existing value is attached to.
Beware : it only works with nodes (not for custom entities), and the field used has to be defined as unique through the unique_field UI.
$field = your field machine name or node property (e.g. 'title')
$scope = 'node'
$ntype = node type (bundle)
$nlanguage = node language ('und' if undefined)
Comment #3
oryx commented