0
votes

I'm trying to find a way to let users select nodes from views results, and then get information from the selected nodes (such as node ID) for use in my module. This would probably be done in a form.

More broadly, what I'm trying to accomplish is to present users with a list of nodes tagged with a certain term x, have them to select any number of nodes from that list, and then have my module apply another term y to the selected nodes. I can handle that last part, but I'm struggling with creating a list of nodes that users can select from, and then somehow getting the information about the nodes selected that way.

I assumed views are the way to go but after a lot of searching I haven't found a way to achieve this functionality. Can anyone can show me a solution or point me in the right direction?

Thanks!

I'm using Drupal 7, and Views 7.x-3.7

EDIT: If I had the ability to select nodes with checkboxes via a module like VBO, I would like to do something like the following (terrible) pseudo-code:

foreach (vbo_selected_node) {
$node = vbo_selected_node -> node;
$nid = $node -> nid;
$node = node_load($nid);
$node->field_vocabulary_field['und'][0]['tid'] = $termID;
}

I hope that makes sense. Basically I want to take each selected node and apply another term to it.

1
Thanks for posting a question! Unfortunately, this one requests an answer that is too broad for Stack Overflow. We generally expect questions to be about a specific problem, usually code-related. You can gain a foundation to help you by following the Drupal documentation or various tutorials. If you encounter specific problems as you write your own code, we will be happy to help. - George Cummins
r u using term reference in the node (content type) - Deepak Srinivasan
Yes, there are two relevant term reference fields (two different vocabularies) attached to the content type of the nodes. The first has the term that the view would use to bring up the list of nodes, the second has the terms that would be programatically attached to the nodes. - user2212873
George Cummins, I have added some code to show more precisely what I would like to do. I hope that helps. - user2212873

1 Answers

0
votes

I've been through a similar scenario and came up with a solution through custom module. I'm not sure if it is the best option but still you can use node_load_multiple() method. A quick reference can be found in

http://eureka.ykyuen.info/2012/08/08/drupal-7-get-mulitple-nodes-using-entityfieldquery-and-node_load_multiple/