views:

95

answers:

2

By default, the Book Copy module will create a new book with the same exact name as the book it is copying. This can become confusing and actually caused one of the site developers to accidentally delete the original book, which was reference in menus and such and left the site in a weird state.

Had the name of the copy been something other than the name of the original, then this problem would never have occurred. I dug through the code but just couldn't seem to figure it out. Any help will be greatly appreciated. Thanks!

+1  A: 

You can use the hook_book_copy_alter() offered in book_copy_copy_book():

...
// The function signature is: hook_book_copy_alter(&$node, $oldbid, $newbid);
drupal_alter("book_copy", $node, $bid, $newbid);
...

So, in a custom module, you could implement the following to achieve a changed title on the new node:

function yourModule_book_copy_alter(&$node, $oldbid, $newbid) {
  // Adjust the title ...
  $node->title = 'Copy of ' .$node->title; // TODO: Change to the variation you want
  // ... and save the node again
  node_save($node);
}
Henrik Opel
A: 

It turned out that I figured it out before I found any answer on here. What I did was replace:

$node->title = t('Clone of !title', array('!title' => $node->title));

with:

if( $node->title == "Project Template" ){
    $node->title = "New Project From Template";
}
else{
    $node->title = t('Clone of !title', array('!title' => $node->title));
}

Inside lone_node_save() function of clone_pages.inc file associated with the node_clone module.

Brian T Hannan
I created a content type called a Project, then created a node of the type Project called "Project Template", which uses a book. So when I go to derive a copy of a project it clones all the content of the book or Project Template. This will make it so the node_clone functions as it normally would except for nodes with the title "Project Template."
Brian T Hannan