0

I have created a new field on an existing content type. The field is called "Global News." It's a checkbox and I need it to be checked for all existing nodes. I ran a SQL query to gather all nodes of a specific type joined with the latest revision ID. Both the "field_data_field_global_news" and "field_revision_field_global_news" tables are populated with the correct fields but the checboxes remain unchecked. Is there another table I need to update so this field is linked to the correct nodes?

I tried editing one of the nodes manually, which worked, but the table entry remains the same which leads me to believe there is another table that needs populating.

Any ideas?

1 Answer 1

0

Drupal acts a bit differently,

1) Can you try cleaning your cache.

2) Write a function in a custom module

function _get_nodes() {
  $options = array();
  $sql = "SELECT nid, type FROM {node}";
  //adjust the query to filter on content types, if needed
  $result = db_query($sql);
  foreach ($result as $row) {
    $node=node_load($row->nid);
    //dpm(node); maybe you have different naming convengion
    $node->field_global_news['und'][0]['value']=1;
    node_save($node);
    unset($node);
  }
  return $options;
 }
2
  • Good call. I'm going to go with field_attach_update as opposed to node_save so it doesn't affect timestamps. Thanks. Commented Dec 4, 2013 at 15:51
  • Good idea as well. Glad that it helped Commented Dec 4, 2013 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.