2

Cannot get node_mass_update(); to update Votes field. $node_ids is an array of node ids and $votes is a number.

    $updates = array('field_votes' => $votes);

    node_mass_update($node_ids,$updates);

My module fires and it tells me that nodes are being updated and gives me a progress bar, but the fields in the nodes are not updated.

1

I've never used (or even seen) that function before, but following the trail down to _node_mass_update_helper(), I think you need to use a format like this:

$updates = array('field_votes' => array(0 => array('value' => $votes)));

That array format is the standard way to update CCK fields in Drupal 6, and since the helper function does this:

foreach ($updates as $name => $value) {
  $node->$name = $value;
}

immediately before calling node_save(), I think that's what the problem is.

  • Thanks! Got it to work with $updates = array('field_votes' => array('und' => array(0 => array('value' => floor($votes))))); – mikeyrocks May 15 '13 at 19:14
0

I've never used (or even seen) that function before, but following the trail down to _node_mass_update_helper(), I think you need to use a format like this:

$updates = array('field_votes' => array(0 => array('value' => $votes)));

That array format is the standard way to update CCK fields in Drupal 6, and since the helper function does this:

  • Hi @user72602, welcome to Drupal Answers. It looks like your answer got cut off. Could you please complete it before it faces deletion due to low quality? Thanks! – Wim Mostrey Feb 9 '17 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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