Commit f747d9f0 authored by Croitor Alexandru's avatar Croitor Alexandru
Browse files

Added hook_node_operations and Actions API integration, so with Views Bulk Operations as well.

Fixed a bug with converting books.
Cleaned up code.
Wrote a bit of documentation.
parent 61ea9eb1
// $Id$
Welcome to Node Convert.
This module allows to convert one or many nodes between different node types.
It can transfer most cck fields, and node-specific options for book and forum types.
Support of more basic types will be in future releases.
Also the module provides an API for converting nodes and cck fields, hooks for processing
additional options of custom node types, integrates with hook_node_operations and Drupal's
Action API.
I. Single node conversion:
1) Set 'administer conversion' and 'convert to x', 'convert from y' permissions.
2) Go to /node/x/convert and follow the provided steps to convert the node.
II. Multiple node conversion (using hook_node_operations)
1) Set appropriate permissions.
2) Go to admin/build/node_convert_templates
3) Create a new template following the the provided steps.
4) Go to admin/content/node
5) Select the correct nodes.
6) Choose "Convert template: x" (based on the template name created above) from the update options.
7) Click Update.
III. Multiple node conversion (using Actions API + Views Bulk Operations)
Note: This requires the contributed modules Views and Views Bulk Operations
1) Set appropriate permissions.
2) Go to admin/build/node_convert_templates
3) Create a new template following the the provided steps (also check Create Action).
3) Create a new view with the options you require.
4) Select Views Bulk Operations as the style.
5) Configure all options as necessary
6) Select as an operation one of the convert templates.
Note: Most probably there will be duplicates of the same template, this is because
VBO uses both Actions API and hook_node_operations to show possible operations
7) Save the view. View it.
8) Select the necessary nodes and click the Convert x button.
Useful API calls:
node_convert_node_convert($nid, $dest_node_type, $source_fields, $dest_fields, $no_fields_flag, $hook_options = NULL);
node_convert_field_convert($nid, $source_field, $dest_field);
hook_node_convert_change($data, $op);
\ No newline at end of file
// $Id$
- Make node_convert independent of CCK
- Implement support for types: poll, blog, og, etc.
- Write more complex SimpleTest tests (that use different cck fields and base types like blog, poll)
- Include watchdog support
- Clean up code, try to increase performance
- Change messages to be more user-friendly
- ? Come up with a better UI
- ? Possibly create more hooks or triggers
\ No newline at end of file
......@@ -35,6 +35,7 @@ function book_node_convert_change($data, $op) {
elseif ($op == 'options') {
$form = array();
if ($data['dest_node_type'] == 'book') {
$options = array();
foreach (book_get_books() as $book) {
$options[$book['nid']] = $book['title'];
; $Id$
name = Node convert
description = "A module that converts a node's type and transfers cck field values"
name = Node Convert
description = "Converts one or more nodes between different node types."
dependencies[] = content
core = 6.x
\ No newline at end of file
// $Id$
* @file
* The node_convert install file.
* Installs necesarry tables for correct node_convert functionality
function node_convert_schema() {
$schema['node_convert_templates'] = array(
'fields' => array(
'ctid' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
'name' => array('type' => 'text', 'size' => 'small'),
'source_type' => array('type' => 'text', 'size' => 'small', 'not null' => FALSE),
'destination_type' => array('type' => 'text', 'size' => 'small', 'not null' => TRUE),
'data' => array('type' => 'text', 'size' => 'medium')),
'primary key' => array('ctid'),
return $schema;
function node_convert_install() {
// Create my tables.
function node_convert_uninstall() {
// Drop my tables.
db_query("DELETE FROM {actions} WHERE callback = 'node_convert_convert_action");
\ No newline at end of file
This diff is collapsed.
......@@ -5,7 +5,7 @@
* @file
* Node convert Simpletest Unit
* Tests for basic Node convert functionality.
* Tests for basic Node Convert functionality.
class NodeConvertTestCase extends DrupalWebTestCase {
......@@ -15,8 +15,8 @@ class NodeConvertTestCase extends DrupalWebTestCase {
function getInfo() {
return array(
'name' => t('Node conversion'),
'description' => t('Creating a node, converting it to another type, delete it.'),
'group' => t('NodeConvert'),
'description' => t('Tests diverse aspects of Node Convert.'),
'group' => t('Node Convert'),
......@@ -73,7 +73,7 @@ class NodeConvertTestCase extends DrupalWebTestCase {
$edit['destination_type'] = $type2_name;
$this->drupalPost('node/'. $node->nid .'/convert', $edit, t("Next"));
$this->drupalPost(NULL, array(), t("Convert"));
$this->assertText(t("The current node has been converted succesufuly."), t("Simple node conversion ui test passed."));
$this->assertText(t("The node @nid has been converted succesufuly.", array('@nid' => $node->nid)), t("Simple node conversion ui test passed."));
$result = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $node->nid));
$this->assertEqual($result, $type2_name, t("The converted node type is equal to the destination node type."));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment