Scenario:

  • You have existing nodes of a certain content type.
  • You make structural changes to that content type, more specific, you add new fields.
  • It would be good if there was an easy/supporting way to update the existing nodes of this content type. Currently you have to lookup and edit every node separately.
  • It would be good, if the owners of the affected nodes were notified automatically after structural changes to a content type. So they know, that they must/can update their node(s).
  • Maybe it would be possible by using the workflow module to change the state of all existing nodes to 'requires update' or something similar. The translation module in Drupal 6 does something similar. If you edit the content of a module, you can manually flag all translations of this node as outdated. On the "translation tab" of that node all translations of that node are marked as outdated then.
  • Batch-Update: Generate an editing form, were certain fields of a certain set of nodes can be updated at once. Nodes are presented in a table-like structure. Nodes are in rows and the fields/widgets to be edited are in columns. This way you could easily update all affected nodes at once.

Comments

karens’s picture

http://drupal.org/node/205821#comment-688888 would be a starting point for this...

farald’s picture

I have the needs for registering various proximity data into each nodes which actually is statistics for a group of nodes in an area( location.module). Because these calculations are heavy to do, I want them done every time a node is updated, instead of every time the node is viewed, as that will make the poor machinery to go into overload quite easily. So, I need something like this mentioned in this thread, to update all the cck fields generated by the "computed field"-module in a "batch" every month (for a given content type).

The easiest way is to batch update every node, at least that's the only idea i've comed up with. But updating every node manually will be a hassle when the site grows:)

In other words, quite eager to see something like this come to life.

summit’s picture

A year and a half further, very much subscribing. Needing solution for adding new cck field to existing nodes.

I was wondering if the following is possible
1) Add the cck_field to the nodetype (this works ok, in my case nodetype = weblinks)
2) Add default values for the cck_field for the nodetype (this works ok)
3) create a node, default values are shown and sumbit node (this works ok)

Now in the content_type_weblinks table for this one particular node the cck_fields are inserted.

4) Would it be possible to bring the cck_field values of this newly created node to all other nodes of the type weblinks in the database?
5) That way all existing node would have the default behaviour.

--
In my case it's about the cck pollfield values. I have already 500+ nodes in the database, and just found out it would be great to add cck polffield fields to the nodes.
I am able to create a new weblinks node, and in this node, the default values of cck_pollfield are shown, and will be saved. But how about the all existing nodes.

the fields in the databasetable content_type_weblinks from the cck pollfield bar_terras are:

 Field  	                      Type  	
nid 	
field_bar_terras_question 	  text 	
field_bar_terras_active 	  int(11) 			 		
field_bar_terras_runtime 	  int(11) 				
field_bar_terras_choice 	  text 	utf8_general_ci  	
field_bar_terras_votes 	  int(11) 			
field_bar_terras_anonymous 	  text 	utf8_general_ci 		 		
field_bar_terras_poll_features

The only instance is for one node. How to copy this information to all other weblinks node in the database please?
greetings, Martijn

ljrweb’s picture

im having a similar issue... my code is below. basically im running a php script to go through and update the body's of my nodes... a couple problems im running into is

1) teaser is not updated automatically
2) the path i had set is overwritten by the default pathauto path (content/[node-title])

any suggestions about how to do something like this?? as you can see i tried both node_save and drupal_write_record..

thanks


<?php
 
// set some server variables so Drupal doesn't freak out
$_SERVER['SCRIPT_NAME'] = '/exec.php';
$_SERVER['SCRIPT_FILENAME'] = '/exec.php';
$_SERVER['HTTP_HOST'] = '[domain].net';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['REQUEST_METHOD'] = 'POST';
 
// act as the first user
global $user;
$user->uid = 1;
 
// Drupal bootstrap throws some errors when run via command line
//  so we tone down error reporting temporarily
error_reporting(E_ERROR | E_PARSE);
 
// run the initial Drupal bootstrap process
require_once('includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
 
// restore error reporting to its normal setting
error_reporting(E_ALL);

require_once('../process/Database.class.php');

$db = new DB('localhost','root','[password]');

$str = "select nid from [db].node where type = '[type]'";

$arr = $db->fetchall($str);

foreach ($arr as $tmp_node) {
	
	$node = '';
	
	$node = node_load($tmp_node);
	
	$body = $node->title.' is blah blah ';
	
	$body .= ucwords(strtolower($node->location['city'])).', California.'; 
	
	$node->body = $body;
			
	try {
	
		/*
        _node_save_revision($node, $user->uid,array('nid'=>$node->nid));
		drupal_write_record('node', $node,array('nid'=>$node->nid));
        */
	
		node_save($node);
		
		echo "...done \n";
		
	} catch (Exception $e) {
	
		print_r($e->getMessage());
		sleep(5);
	
	}
	
	$tmp_node = '';
	
}

cache_clear_all();