how to get current result / row into the action hook

gunzip - June 5, 2009 - 10:11
Project:Views Bulk Operations (VBO)
Version:6.x-1.x-dev
Component:Miscellaneous
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

hello, i'm writing a custom action. i need to obtain from the view the current row/values being processed
into the mymodule_action hook (i wonder if this is possible through the variable $context->view)

i know i can get a single object loaded with my custom load function but what i need are the values in the current row, not some object (node, user) property.

thank you in advance!

#1

kratib - June 5, 2009 - 16:22

Yes, the $context->view->result array should contain the row values. Two caveats:
* You will need to manually find the entry in $context->view->result that corresponds to the object passed to the action.
* In case of a global selection (across all view pages), the $context->view->result will not contain all results, only those for a single page.

Hope that helps. Feel free to produce patches that fix those caveats :-)

#2

gunzip - June 8, 2009 - 15:11

I ended up calling the view again and getting the results in my custom action with pagination off.

The issue is that, when in batch mode, the view object passed in the context is:

public '__PHP_Incomplete_Class_Name' => string 'view' (length=4)

so i cannot use it anyway. Any hint ? =)

#3

kratib - June 9, 2009 - 03:43
Category:support request» bug report

That was a bug! Thanks for reporting it. I committed a fix, so please try it in the latest dev (12 hours from now).

#4

gunzip - June 10, 2009 - 14:01

ok now I can get the row result but there's an issue: if I have 3 different rows that come from the same node
(ie. the same cck field repeated into the same node with different values) the action is called only once
because the nid is still the same. is there a way to overcome this ?

#5

gunzip - June 10, 2009 - 15:39

(ok i solved this cycling on results)

 
 

Drupal is a registered trademark of Dries Buytaert.