I have my default settings for most node types set up to publish the nodes immediately. However when I clone a node, I don't want it to be published immediately, because I usually need to edit it a bit before it's ready to "go public". This patch (for 4.7) adds extra checkboxes to the settings page to allow cloned nodes of a given type to be NOT published.

This overrides the publishing setting regardless of the default settings for the node type.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jjeff’s picture

Version: 4.7.x-1.x-dev » 5.x-1.0-beta

good point

jjeff’s picture

Version: 5.x-1.0-beta » 4.7.x-1.x-dev

Doh!

Ignore that last post.

pwolanin’s picture

Maybe this should be generalized more to include moderated, demoted, etc.?

Also, there is already an option to reset the publishing options upon cloning- is your content type set to published or unpublished by default?

jjeff’s picture

My settings for this node-type are set to default to published -- as is the case with most of my node types.

The problem: I can't imagine why *anyone* would want a node entitled "Clone of [Name of Content]" to appear live on their site for any amount of time. They will usually edit the clone and update the content... maybe a new date for a new workshop... maybe a new location for a different store... whatever. But if an RSS reader comes along while they're editing, it'll pick up "Clone of [Name of Content]". Not cool.

The truth is that the node shouldn't be saved into the database when it is cloned. It should simply populate the node editing form as a new node... and then save (for the first time) when the form is submitted. I'm not sure how practical it is to do this though. I've had really good luck using this module to clone items like WebForm nodes and it works fine. I doubt that it would work without actually cloning the node object and running it through node_save() before editing.

pwolanin’s picture

Status: Active » Needs review

Yes, I was thinking recently about possibility of populating the form instead of saving the node first. Of course, saving the node first doesn't always work either.

I understand your concern, and I'll look more at the patch.

jjeff’s picture

Perhaps a better solution is to clone ALL nodes as unpublished (so they're not live) and then do a form_alter() on the editing form to set it up with the default values as set for that node-type. This way you could remove *all* of the settings for the module -- except for the confirm setting I guess...

That would be kinda nice actually. :-)

pwolanin’s picture

FileSize
3.29 KB

Try this- a different version of the module for 4.7 (whole module attached followed by a patch)- it just pre-populates the node form, rather than saving to the DB first. Haven't tried it with any complicated nodes yet, but it works for simple ones and avoids the temporarily bad content issue.

pwolanin’s picture

FileSize
2.86 KB

in patch form vs. 4.7

joestewart’s picture

Thanks for the patch to only prepopulate the form. This works much better for my 4.7 site. I was having errors with nodes that have attachments. upload_image module spit out this error:

Fatal error: Cannot use object of type stdClass as array in /var/www/apache2-default/drupal/modules/upload_image/upload_image.module on line 137

No problems while testing this patch.

anders.fajerson’s picture

I tried the patched module with the Advanced Poll module which has a pretty advanced node form (where this module could be a real timesaver).

In my limited testing it worked without errors (the 4.7.x or 5.x release does not work for all fields). Any plans on releasing this version for Drupal 5? To me this seems like the right approach to clone a node. Great work.

pwolanin’s picture

Yes, I'll do it for 5.x sometime soon. My only question is whether to continue both versions for 5.x and beyond?

pwolanin’s picture

Title: Patch to add setting for unpublished clones » Cone by pre-populating the node form, rather than saving to DB

fixing title

pwolanin’s picture

Title: Cone by pre-populating the node form, rather than saving to DB » Clone by pre-populating the node form, rather than saving to DB
anders.fajerson’s picture

Personally I don't see any benefits of doing it the old "DB" way, if that was what you asked for.

pwolanin’s picture

Here's a patch for 5.x- works with OG at least, in addition to simple node types. I'll have to look at the 4.7 patch again to see if I'm setting the form ID correctly.

pwolanin’s picture

This one might be better- also unsets the list of file attachments to prevent a false listing in the node form.

anders.fajerson’s picture

Patch (5.x) applies and works with advanced poll forms.

Just a small thing: most modules use the same project/folder/file-name, this one uses both node_clone and clone. Might be a thing for the stable 5.0 release.

anders.fajerson’s picture

One more thing: I see that you removed some settings. But isn't the publish option also redundant with the non-db approach? Would be sweet without a settings page.

pwolanin’s picture

someone else had the "contributions/modules/clone" when I started this, so the discrepancy has been there all along.

The setting is to reset the publishing options (e.g. promoted, sticky etc), so I think it's a needed feature still. Imagine you let a non-admin clone nodes- they clone one on the front page, but you might not want their new post to also be on the front page without your approval.

anders.fajerson’s picture

I see. How about making that the reset behaviour default for users without admin permission and just provide a "Note: Publishing options has been reset"? No settings. Just an idea. Maybe there are cases where you really want the publishing options to stick...

pwolanin’s picture

I committed the 2 patches to the DRUPAL-4-7--2 and DRUPAL-5--2 branches- so you can pull those out of CVS if you want to test the module in "pre-populate" mode (e.g. "$ cvs co -r DRUPAL-5--2 contributions/modules/node_clone").

anders.fajerson’s picture

Did that. I did expect an updated Drupal-5 branch though. Anyway, this release is great, thanks again.

jjeff’s picture

Please test this with webform nodes. Node-types don't get much more complex than that... and you actually have to go to a separate page to edit form fields... The "old" method works just fine for these nodes, but I'm nervous that this new method won't. I haven't had a chance to test this yet though...

Sorry for the incomplete critique.

hass’s picture

@pwolanin: please support 4.7.x for a while. For me - i cannot change to 5.x today while there are so many modules not upgraded, ready or buggy for 5.x :-(

hass’s picture

@fajerstarter: do you like to change the filename "clone.module" to "node_clone.module", too? i'd like to see this fixed, too.

pwolanin’s picture

@haas - this is a simple enough module that I'll fix any bugs in any of the 4 current versions (2 for 4.7.x and 2 for 5.x)

pwolanin’s picture

@jjeff - a quick test with DRUPAL-5 webform and the DRUPAL--5-2 version of this module seems to work fine.

leoklein’s picture

+1 for switching to pre-populating the form. I come to Clone after using 'Edit as New' for quite a while and this seems more intuitive.

Thanks.

pwolanin’s picture

Status: Needs review » Fixed

@patachon - this is available as the 5x.-2 branch on the download page- please provide any feedback on the functionality.

Anonymous’s picture

Status: Fixed » Closed (fixed)

  • Commit bd03966 on 6.x-1.x, 7.x-1.x, master, 8.x-1.x by pwolanin:
    #110294 switch to pre-populating the node form, rather than directly...