Looping through all nodes of a content type and copying one textfield of the node into the body field

Events happening in the community are now at Drupal community events on www.drupal.org.
marcusx's picture

Hi!

Is it possible to loop through nodes with the Rules 2 for D7? This documentation says only something about looping through a multi value field. http://drupal.org/node/943962

I wwould like to go through all page content nodes and if the body field is empty the text from another textfield in the node should be copied. I tried to create an action set and selected "List of node items" in the variable settings. I see it in the loop data selector list but how can I populate this list?

Is there some further documentation?

Thanks for your help.
Regards
Marcus

Comments

VBO?

itangalo's picture

One way of approaching your problem is to use Views Bulk Operations to update your nodes. Views Bulk Operations allows you to run customized actions (such as Rules' action components) on selected nodes.

A brief outline:

  • Add an action set in Rules, copying the text field value to the body. (You will need the set data value action for this.) Make sure that the action set has one argument/parameter – a node.
  • Build a view listing all nodes where the body field is empty.
  • Add a VBO node action field to your view. Select the action set you built.
  • Visit your view, check the nodes you want to update (such as all of them), and run the action.

Good luck!
//Johan Falk
**
Learn Drupal with Nodeone! Drupal 7 introduction | The Views module | Learn Page manager! | Drupal configuration learning curve | Learn Drupal coding | Rules for Drupal 6 | Theming Drupal 6 | 49 Drupal 6 modules you should know

Ahh ok thanks, I used it with

marcusx's picture

Ahh ok thanks, I used it with VBO before, but thought this is not neccessary any more with this loop stuff in 2.x. I will try again with vbo.

You might also use the

socialnicheguru's picture

You might also use the database itself:
UPDATE node_revisions, content_field_article SET node_revisions.body = content_field_article.field_article_value WHERE node_revisions.vid = content_field_article.vid;

http://drupal.org/node/165370

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: