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
| Attachment | Size |
|---|---|
| optional-clone-title.patch | 2.29 KB |

#1
looks reasonable, but please roll against 6.x (HEAD) first.
#2
Here is a version rolled against HEAD.
--Andrew
#3
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
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
+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
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.
#7
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
#6 is certainly CNW, since the t() call is useless as written
#9
I'd be happy to do anything I can. Could you outline what the problem is?
#10
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
So what is the solution?
#12
Automatic Node Titles will do this and that's what is being used on http://drupalbin.com .
#13
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
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
To make the "Clone Of" node titles optional like you see on http://drupalbin.com , do the following:
Hope that helps! Or am I accomplishing something different here?
#16
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
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
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
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
bah.
#21
? 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
@Rob Loach - doesn't that still violate the principle of not passing dynamic text through t()?
#23
Yeah, probably. I just can't think of another way around it.... Tokens?
#24
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.