I'm interested in extending this module so that a user can choose to clone a node, and then save the clone as a template. The templates could have individual names, and be accessed from a "My Templates" menu entry. When the user wants to create a new node, they can click on "My Templates" and choose the template they want, a new node will be created, opened in an edit window with all of the Taxonomy and Publishing options pre-set.


pwolanin’s picture

Hmmm, why not just use the existing nodes as the templates? Seems like you'd be halfway there at least.

Or, with the "reset publishing options", you could even have the template nodes be unpublished- you could just make a little block showing each user his unpublished nodes (templates) and construct the link to node/nid/clone. The only trick is to how to let users add nodes to this template list without letting them unpublish other site content.

To really customize this module for your particular needs would probably require some substantial development and probably a new module (the clone module is actually a relatively simple piece of code). You could either take this module as a basis to do it yourself, or sponsor development.

Chill35’s picture

I agree with pwolanin. I am using the module myself, and I think that with the module "as is", you can certainly make an unpublished node a template. Then you can clone that "template node" (you can even use the word "template" in its title), and modifiy some fields, as well as the title... and publish that clone. The fields would not be php fields, but can look exactly like... fields.

Let me give you an example :

- CREATE a node, mark it "unpublished", and give it this title : Template for annoucement.

- Fill it with all that should always be there, and put in place of your "variables" words in square brackets, such as [DATE], [NAME OF...]

- If you use php you can even use some code to retrieve information in a "smart" (dynamic) way in that node.

And then create a menu with links to these unpublished nodes.

You can also look at the following module : PageRoute, which does provide a "route" for creation of nodes. NO templates as such.

Good luck!

Chill35’s picture

mark it "unpublished" ----> do NOT make it as published.

Sorry about that.

Anonymous’s picture

Thanks to both of you. I'll look into these suggestions :-)

GC_Chi’s picture

I just want to add that I think that using the clone module to create templates is a great idea. I was originally planning on using the prepopulate module, but it proved to be too limited. I eventually realized that the cloning module would do exactly what I wanted. I created node templates as you guys described and then replace the default "Create content" links with menu links that linked to "node/xxx/clone."

However this use of the clone mod is not obvious. In the dozens of posts about using prepopulate, no one mentions the clone mod. It would be an awesome extension of this essential mod to have be able to define templates, manage them in admin area and create template/clones in the menus or blocks.

Just my two cents. Thanks for this great mod.

Chill35’s picture

Eaton, if you read this, I think it would be awesome to add a line on the module project page saying : you can use this module to allow pseudo node templating... something like that.

pwolanin’s picture

Caroline, since it's my project, I'm not sure why you are appealing to Eaton??

Chill35’s picture

LOL... it's you allright.

Sorry, I don't know what that lapsus means. ;)

pwolanin’s picture

Status: Active » Closed (fixed)

Added a link to the project page; closing since this is not a feature I'm not planning to support via any additional code.

1kenthomas’s picture

"stub:" what I would like to do is "mass clone--" create multiple nodes with data (such as directory, tax tags) filled by an argument. (As this may be possible via the current module once I look at it, I'll move on...).


pwolanin’s picture

Version: 4.7.x-1.x-dev » 6.x-1.x-dev

for 6.x, here's a quick and dirty approach to restrict which nodes can be templates.

This is an add-on module, but more likely you'd put this code in some other larger module of site-specific hacks.

file: template_node.info

; $Id$
name = Clone template nodes
description = "Allows users to clone only nodes whose title starts with the word Template."
core = 6.x

file: template_node.module

// $Id$

 * Implementation of hook_clone_access_alter().
function template_node_clone_access_alter(&$access, $node) {
  $access = $access && (stripos(trim($node->title), t('Template')) === 0);

You could also so some other things if you are using simple node types - e.g. you could only allow 'page' nodes to be cloned and then on the subsequent alter hook, turn them into 'article' nodes.

miro_dietiker’s picture

Checking for a match of t('Template') in a node title depends current language the node was reached. Please note it is generally possible that a node in german gets displayed with a current chosen language english.

This highly depends module setup and locale settings and is not the right way...

momper’s picture


chefarov’s picture

Book page clone misses child pages. I think the most import functionality in node cloning modules.

Is this going to be implemented?

tonyoconnell’s picture


Kami Petersen’s picture

Anticosti’s picture


WorldFallz’s picture

Just an fyi--

i used the code in #11 but used a simple checkbox field to indicate whether or not the node should be considered a template then setup a view listing these template nodes with node/xxx/clone links to use the template. Also, I used field_permissions to control which roles can designate a node as a template. Works great.

blueantlabs’s picture

Post your code WorldFallz if you don't mind!

WorldFallz’s picture

yep-- i shoulda posted it. Here it is:

* Implementation of hook_clone_access_alter().
function template_node_clone_access_alter(&$access, $node) {
  $access = $access && ($node->field_template['und'][0]['value'] == 1);

where field_template is a simple single on/off checkbox.

kenorb’s picture

Great, I did the same feature of the templates (message templates). It only took two content types (template and actual content), a view and the hook from #20.

fuerst’s picture

FYI: Based on Node Clone I implemented a template mechanism this way: When adding a node you may click a link "Create from template" which let you choose from a list of nodes marked as template. After choosing a template node you get a node edit form prefilled with content from the template. Marking a node as to be used as a template is done by checking a box at the "Node Template" setting in the node.

Please have a look and let me know what you think about it:

motou’s picture

Issue summary: View changes

the module Node Template does exactly what it is wanted. http://drupal.org/project/node_template

In that module any kind of node can be defined as a template, then one can create a node from that template.