I'm using Node Clone v2 along with Node Expire. I need Node Clone to reset the expiration date on Node Expire, whenever I clone a node. Currently, it clones EVERYTHING including the expiration date, rendering the new node, useless. I've switched to v1 temporarily, but I hate the way it creates a node, and then let's you edit it.

Is there a way to exclude certain fields from the cloning process?

This is quite urgent.

Comments

pwolanin’s picture

Well, the short answer is that this is a very simple module that treats all fields equally (except for some configurable bis with the publishing options), so if you want specific functionality like this the easiest thing would be to make your own version of the module.

cdemetriadis’s picture

Would you be willing to throw some pointers? I just need to exclude a field form the cloning process. Where would I start?

pwolanin’s picture

take a look at the code:

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/node_clone/...

this is the one function that actually does the work:

/**
 *  Clones a node - prepopulate a node editing form
 */
function clone_node($nid)
{
  if (is_numeric($nid)) {
    global $user;
    
    $node = node_load($nid);
    if (isset($node->nid)) {
      
      $node->nid = NULL;
      $node->uid = $user->uid;
      $node->created = NULL;   
      $node->menu = NULL;
      $node->path = NULL;
      $node->files = array();
      $node->title = t('Clone of @title', array('@title' => $node->title));
      drupal_set_title(check_plain($node->title));
      
      if (variable_get('clone_reset_'. $node->type, FALSE)) {
        $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
        // fill in the default values
        foreach (array('status', 'moderate', 'promote', 'sticky', 'revision') as $key) {
          $node->$key = in_array($key, $node_options);
        } 
      }
      if (empty($_POST['op'])) {
        drupal_set_message('This clone will not be saved to the database until you submit.');
      }
      return  drupal_get_form($node->type .'_node_form', $node); 
    }
  }
}

see how $node->menu, etc are treated (set to NULL or unset). You'll want to do this for any/all of the node expire fields.

cdemetriadis’s picture

OK, will try that out.

Thanks allot!

cdemetriadis’s picture

It worked fine, thx!

pwolanin’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.