Jump to:
| Project: | Node clone |
| Version: | 5.x-2.0 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
This is kind of an odd setup, but I'm hoping someone can suggest how I might fix this.
We use a slightly modified version of casetracker as a log for documents. Each document needs a unique 3 character ID for compatibility with another system, but there can be more than 1000 documents in a fiscal year. I use some PHP to convert the Casetracker ID to Base 36 and store the result in a calculated field (using CCK).
Recently I had to change the calculation slightly, and we discovered that this field was being recalculated any time the node was edited, which meant the IDs were changing for nodes created before the calculation change. This is bad. So I added some PHP to not change the value of the calculated field if it already had a value. That worked, but now if the users clone a node, they get stuck with the same code that the pre-clone node had, even though the case ID has changed. For now, we aren't cloning these nodes, but that's very inconvenient for the users.
Here's my calculated field code:
if (!$node_field[0]['value']) {
$old_suffix = $node->field_old_suffix[0]['value'];
$new_suffix = strtoupper(base_convert($node->case_number+32401,10,36));
if ($old_suffix) $new_suffix = $old_suffix;
$node_field[0]['value'] = $new_suffix;
}Is there anything I can check for to see if this is a fresh clone when deciding whether to recalculate the contents of this field? Or is this an example of a case when I should be using hook_clone_node_alter? Is there any documentation on how to use hook_clone_node_alter?
Thanks!
Comments
#1
I ended up converting this setup to CCK with lnids instead of using CaseTracker, and now I am able to adjust module weights, etc. to deal with this.