Skip to main content
18 events
when toggle format what by license comment
Apr 13, 2017 at 12:47 history edited CommunityBot
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Mar 10, 2016 at 7:22 vote accept Tushar
Oct 25, 2014 at 16:22 comment added J. Reynolds Good question and answer. The docs for views_db_object::add_item linked to in answer has a comment by @jnicola that describes using get_items() and get_item() to get to the options.
Oct 25, 2014 at 14:12 comment added Tushar able to remove ajax error by adding view execute. function registration_export_views_pre_view(&$view, &$display_id, &$args) { if ($view->name == 'registrations_export') { $view->execute(); dpm($view);}}
Oct 25, 2014 at 13:04 comment added Tushar Is there any alternative to discuss with you please suggest actually i dont have enough reputation to go inside chat room.
Oct 25, 2014 at 13:03 comment added Tushar Yes i have and the below code working function registration_export_views_pre_render(&$view) { if ($view->name=='registrations_export') { dpm($view); } }
Oct 25, 2014 at 12:59 comment added rooby Do you have the devel module enabled? you need it for dpm(). You're also now calling views_db_object::add_item() which will break. You used to have $view->add_item() which is correct. The system doesn't like conversations in comments so I can help further in chat if you have more questions.
Oct 25, 2014 at 12:57 comment added Tushar Truly speaking i am not getting any more handler only 3 handler in view export as i have added in my code.
Oct 25, 2014 at 12:52 history edited rooby CC BY-SA 3.0
Adding more information about views dev & options array
Oct 25, 2014 at 12:44 comment added Tushar i have try to write this but it give me ajax error function registration_export_views_pre_view(&$view, &$display_id, &$args) { if ($view->name == 'registrations_export') { dpm($view);}}
Oct 25, 2014 at 12:42 comment added rooby Compare your current example to the examples I gave. They look vastly different. You don't pass in the whole views export lines just the values. The $handler->display->display_options['fields']['field_contact_email'] part of the export is telling you which field it is, then the option names, then the option values. Plus you already pass in table, field, id as other function params outside the options array. The devel module dpm() method of discovering field structure is probably going to be more useful for learning. I'll do one more quick edit to illustrate what I'm getting at.
Oct 25, 2014 at 12:10 comment added Tushar Still my updated code missing something.
Oct 25, 2014 at 11:37 comment added rooby The example hook_views_pre_view() in my answer and in the question are accurate but you can call it anywhere you have the $view object by doing $view->add_item(); It generally needs to be called before the view runs or else there is no point adding the item. The other stack exchange answer I linked to can be done from anywhere as it loads a view, then adds an item, then executes the view. If you're not manually executing the view then hook_views_pre_view() is a good place for it.
Oct 25, 2014 at 11:30 comment added DRUPWAY Thanks @rooby, actually this is new for me. one more question the function definition (views_db_object::add_item($display_id, $type, $table, $field, $options = array(), $id = NULL)) can i write inside hook_views_pre_view() or how i call this function?
Oct 25, 2014 at 11:19 comment added rooby I have updated my answer. The exported view won't give you the exact array you need to pass in but it helps with keys and values. Another thing you can do is install the devel module and do a dpm($view) or dpm($view->fields) or something along those lines to see the fields in a better array structure. That will probably help more than the view export.
Oct 25, 2014 at 11:17 history edited rooby CC BY-SA 3.0
Added more info on OP edits.
Oct 25, 2014 at 10:55 comment added Tushar as per your suggestion i have tried the code but i think i am missing some where can you please look my updated code. Also i have checked by export the view. But not getting the array like above.
Oct 25, 2014 at 10:22 history answered rooby CC BY-SA 3.0