Make 'Clone Of' title optional

deviantintegral - August 12, 2008 - 19:04
Project:Node clone
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Hi,

I've attached a patch which makes the title modification an optional setting. It defaults to on, so it won't change any existing installations. If you disable the title modification, instead a message is set with a link to the original node.

It's pretty simple, and will make a big difference for my users who keep forgetting to remove the Clone of (the titles aren't supposed to be modified).

Enjoy!
--Andrew

AttachmentSize
optional-clone-title.patch2.29 KB

#1

pwolanin - August 20, 2008 - 18:13

looks reasonable, but please roll against 6.x (HEAD) first.

#2

deviantintegral - August 20, 2008 - 18:52
Version:5.x-2.x-dev» 6.x-1.x-dev

Here is a version rolled against HEAD.

--Andrew

AttachmentSize
294442-optional-clone-title.2.patch 2.31 KB

#3

drewish - November 5, 2008 - 20:20

it'd be kind of cool if the text was a variable so you could do something like "!title - cloned" or "FIXED: !title".

update: you could of course set it to "!title" and achieve the goal of this issue.

#4

deviantintegral - November 26, 2008 - 23:05

How about using the token module? I'd like to avoid introducing another method of tokens. It should be simple to make token not required, but used if available. Though making token required might be simpler.

#5

Boris Mann - February 1, 2009 - 02:35

+1 for this feature. I think it should work like this:

If token module is not installed, then it might be as simple as an on / off checkbox for pre-pending this text. There is a note next to this setting that says "install token module for advanced settings".

If token module IS installed, then "advanced behaviour" is turned on, and you have a text field to enter in tokens.

#6

psynaptic - May 27, 2009 - 15:04

I created this patch before I saw this issue. My patch is much simpler so much more chance of it being committed.

I have to delete the "Clone of " text for each node I clone and I clone about 1-200 nodes per project! I'm really hoping this will get committed.

AttachmentSize
node_clone-cloned_node_title_prefix.patch 1.69 KB

#7

psynaptic - May 27, 2009 - 15:07

Another feature I would like is the ability to increment any numeric value found in the title.

My use case is:

1. Create node with a title such as "Event Title 1".
2. Clone the node and the title ends up as "Event Title 2".

This would save me a lot of time.

It would also be great to be able to clone a node multiple times using this increment.

#8

pwolanin - June 8, 2009 - 01:55

#6 is certainly CNW, since the t() call is useless as written

#9

psynaptic - June 8, 2009 - 11:48

I'd be happy to do anything I can. Could you outline what the problem is?

#10

pwolanin - June 8, 2009 - 22:04

As written the call to t() does nothing except pass through to strtr().

Also, you can already localize this to just '!title', so it is optional already.

#11

psynaptic - June 10, 2009 - 18:57

So what is the solution?

#12

Rob Loach - June 11, 2009 - 18:35
Status:needs review» by design

Automatic Node Titles will do this and that's what is being used on http://drupalbin.com .

#13

drewish - June 11, 2009 - 19:01

Rob Loach, it's not clear to me how to use Automatic Node Titles to only set the title on cloned nodes. Could you elaborate a bit?

#14

psynaptic - June 14, 2009 - 09:30
Status:by design» needs review

I can't figure out how to achieve this using ANT either.

I have used that module a lot for specific node types but I don't think it's applicable here.

#15

Rob Loach - June 15, 2009 - 15:29

To make the "Clone Of" node titles optional like you see on http://drupalbin.com , do the following:

  1. Install Clone Node module
  2. Make a node type clonable
  3. Install Automatic Node Titles module
  4. Edit the node type at admin/content/node-type/%nodetype% and use "Automatically generate the title if the title field is left empty". DrupalBin uses "[type-name]" for the replacement pattern

Hope that helps! Or am I accomplishing something different here?

#16

psynaptic - June 15, 2009 - 15:33

What you describe *could* work but I don't think it would be very smooth. It means you have to set it up, then turn it on and off each time you want to switch between being able to clone a node type and revert to normal behaviour.

The solution I provided a patch for works but I agree it's not great. I though pwolanin might have the answer to the bad use of t() so I could learn and refactor.

#17

Rob Loach - June 15, 2009 - 15:41

OH! You're saying customize the "Clone of" prefix text? Sorry, I didn't interpret it correctly. To do this on DrupalBin, I used String Overrides and stuck "Clone of !title" in as an override. In this case I changed it to "Fix for !title". I would love for this to be part of Clone Node core though.

Thanks!

#18

psynaptic - June 15, 2009 - 16:10

Hehe, np. :)

I hope this or a similar fix gets committed. I don't mind patching the module each time but would be easier for everyone to have the option built-in.

#19

Rob Loach - June 15, 2009 - 17:15
Status:needs review» needs work

Again, you don't have to patch the module. Just use String Overrides ;-) .

As for this going into Clone Node modules itself, I don't think it should be regarded as just a prefix because what if you wanted to make it "!title: Cloned Version" or something? I think it should rather be called "Title Pattern", or something along those lines, and provide replacement patterns like !title, like how the User Settings page does it. Having this replacement pattern though, removes the ability for internationalism. Translations don't work on dynamic text since the variables table isn't translated. Hmmmmmmmm............

#20

psynaptic - June 15, 2009 - 23:21

bah.

#21

Rob Loach - June 20, 2009 - 17:30
Status:needs work» needs review

? node_clone-cloned_node_title_prefix.patch
Index: clone.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.pages.inc,v
retrieving revision 1.3
diff -u -p -r1.3 clone.pages.inc
--- clone.pages.inc 7 May 2008 02:28:58 -0000 1.3
+++ clone.pages.inc 27 May 2009 15:00:13 -0000
@@ -1,6 +1,6 @@
<?php
// $Id: clone.pages.inc,v 1.3 2008/05/07 02:28:58 pwolanin Exp $
-// $Name:  $
+// $Name: HEAD $

/**
  * Menu callback to configure module settings.
@@ -24,7 +24,13 @@ function clone_settings() {
     '#options' => array(t('Require confirmation (recommended)'), t('Bypass confirmation')),
     '#description' => t('A new node may be saved immediately upon clicking the "clone" tab when viewing a node, bypassing the normal confirmation form.'),
   );

+  $form['basic']['clone_format'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Node title format'),
+    '#description' => t('Enter the formatting for the node title.'),
+    '#default_value' => variable_get('clone_format', 'Clone of !title'),
+  );
+
   $form['publishing'] = array(
     '#type' => 'fieldset',
     '#title' => t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?'),
@@ -123,7 +129,7 @@ function clone_node_prepopulate($origina
       }
       $node->path = NULL;
       $node->files = array();
-      $node->title = t('Clone of !title', array('!title' => $node->title));
+      $node->title = t(variable_get('clone_format', 'Clone of !title'), array('!title' => $node->title));
       drupal_set_title(check_plain($node->title));

       if (variable_get('clone_reset_'. $node->type, FALSE)) {

How about this? It's still kind of translatable because it's passed through t().

#22

pwolanin - June 20, 2009 - 21:56

@Rob Loach - doesn't that still violate the principle of not passing dynamic text through t()?

#23

Rob Loach - June 21, 2009 - 07:18

Yeah, probably. I just can't think of another way around it.... Tokens?

#24

pwolanin - June 21, 2009 - 14:15

I'd be fine with using toekn module as long as the default is still to localize this.

E.g. the user could save to the variable anything suitable for standard node token replacement if token module is available. Thus, if the variable is non-empty the token replacement is done, otherwise it localizes it as it does now.

 
 

Drupal is a registered trademark of Dries Buytaert.