Record and view ancestor of clone
turadg - August 18, 2009 - 22:05
| Project: | Node clone |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Description
On my site I want users to able to clone and make their own versions of nodes, but I also want users to be able to see what derivatives have been made. For example, a block that shows what other nodes were made by cloning the viewed node. Then users could click into that block to see the clone, and what clones have been made of it.
I see this as requiring two chunks of work:
1) Make and update a table such as {clone_relation} that pairs parent and child clones.
2) Make a block that displays clones for the viewed node.
Does anyone else have use for this? If a patch is submitted for it, how inclined are the maintainers to commit it?

#1
Since not everyone will want the tables necessary to keep track of this, I made it a separate module that can be installed and uninstalled. It makes use of the handy clone_node_alter hook.
I've attached the whole module as a ZIP.
Unfortunately, it's not working yet for the 'prepopulate' method of cloning because the clone ids aren't known at prepopulation time and the original ids aren't known at node save time. For the 'save-edit' method, I added a property, 'clone' array, to the node, but it gets lost through the edit form.
If anyone has any advice on how to make 'prepopulate' work, I'd appreciate it. Maybe something with a form alteration?
#2
You should be able to use the alter hook to copy the nid onto the new object, though really this would not be a big deal to include in the main module. In any coase there is some code duplication that should be reduced. I think you would then need a form_alter in the prepopulate case in roder to propagate the data through from the form to the node_save().
#3
I enhanced the module clones_history so that it also works for the prepopulate method.
I added some code, to have the clones_history information available when a node is loaded. I also added some code to show this information.
#4
just figured it is indeed nicer to have it as a block, like turadg asked for, so i did that. New Version is attached and if you don't want a block, but want to put the info in the node body you can still insert in it your node template by calling:
<?php print theme('clones_history', $node); ?>obviously you can override the theme function by creating phptemplate_clones_history($node) in your template.php
I would guess that it would be a good idea to put this module in the node_clone folder so it gets distributed with the clone module but you have to activate it seperatly. Or merge the code with the clone modules code. either way...
#5
sorry, forgot the attachment...