0

I have used editable views module to get a single page to edit the nodes. I want to store the updated details to an external table.

I have used hook_node_update but it only saves the first node's value to my external table not the rest of nodes(I have 18 nodes in a single page to edit).

function pmr_data_table_node_update($node) {

  if($node->type == 'upload_data'){
    $node_id = $node->nid;
    $profit = $node->field1['und'][0]['value'];
    $satisfaction = $node->field2['und'][0]['value'];
    $from = $node->field3['und'][0]['value'];
    $to = $node->field3['und'][0]['value2'];


    $newDate = date("Y-m-d H:i:s", strtotime($to));

    $entry = db_update('table_name')
     ->fields(array(
     'profitability' => $profit,
     'customer_satisfaction' => $satisfaction,
     ))
     ->condition('nid', $node_id, '=')
     ->condition('to_date', $newDate, '=')
     ->execute();
    drupal_set_message('Data updated successfully.'); 

  }

}

The above code only saves the first node in the editable view list. Can anybody suggest how can I save all the field values in a single round? Is there any hook where I can use to save the all the changed field values to the external table?

OR

Is there any hook by which I could get the data just after the set of nodes are updated?

1 Answer 1

0

The thing I didn't understand is how are you updating the nodes? you said in a single page edit? what does this mean? do you mean vbo? or is it in node page view?

Because your code seems right and should run on every node and if you are using vbo so it would be an issue related to it!

if you can explain more I'd be happy to help

2
  • I am using a module named editable views where editable fields can be added. If we use views which have multiple nodes, then we can carryout edit to all nodes from a single page. Sep 6, 2018 at 11:09
  • I can see you mentioned that in your question, OK did you look into this issue in the module's issues? it could be related to the module and how it handles Drupal hooks for bulk operations, to be sure use another method like vbo and do some bulk update for nodes to see if you hook works there, just to be sure the module isn't doing its work properly Sep 7, 2018 at 21:20

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.