0

I have a custom database table. I implemented hook_views_data() to make it available with views.

/** * Implements hook_views_data(). */ function uploader_views_data() { $data = array( 'texts' => array( 'table' => array(), ), ); $data['texts']['table'] = array( 'group' => t('Uploaded Texts'), 'handler' => 'views_join', ); $data['texts']['table']['base'] = array( 'field' => 'txt_id', 'title' => t('Texts'), 'help' => t("Text ცხრილში ინახება ინფორმაცია ტექსტების შესახებ. მაგ: ავტორი, სათაური და ა.შ"), 'weight' => -10, ); $data['texts']['txt_id'] = array( 'title' => t('txt id'), 'help' => t('ცხრილის უნიკალური ID-ი.'), // The help that appears on the UI, // Information for displaying the nid 'field' => array( 'handler' => 'views_handler_field_node', 'click sortable' => TRUE, ), // Information for accepting a nid as an argument 'argument' => array( 'handler' => 'views_handler_argument_node_nid', 'name field' => 'title', // the field to display in the summary. 'numeric' => TRUE, 'validate type' => 'nid', ), // Information for accepting a nid as a filter 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), // Information for sorting on a nid. 'sort' => array( 'handler' => 'views_handler_sort', ), ); $data['texts']['teqstis_saxelcodeba'] = array( 'title' => t('ტექსტის სახელწოდება'), 'help' => t('ნაბეჭდი ტექსტის სახელწოდება.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, // This is use by the table display plugin. ), 'sort' => array( 'handler' => 'views_handler_sort', ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), 'argument' => array( 'handler' => 'views_handler_argument_string', ), ); $data['texts']['xelnaceris_saxelcodeba'] = array( 'title' => t('ხელნაწერის სახელწოდება'), 'help' => t('ხელნაწერის სახელწოდება.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, // This is use by the table display plugin. ), 'sort' => array( 'handler' => 'views_handler_sort', ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), 'argument' => array( 'handler' => 'views_handler_argument_string', ), ); $data['texts']['type'] = array( 'title' => t('Type'), 'help' => t('ტექსტის ტიპი.'), 'field' => array( 'handler' => 'views_handler_field', 'click sortable' => TRUE, // This is use by the table display plugin. ), 'sort' => array( 'handler' => 'views_handler_sort', ), 'filter' => array( 'handler' => 'views_handler_filter_string', ), 'argument' => array( 'handler' => 'views_handler_argument_string', ), ); return $data; } 

I want to create a custom bulk operation on this table.

function uploader_action_info() { return array( 'uploader_myaction' => array( 'type' => 'entity', 'label' => t('Do my action'), 'configurable' => FALSE, 'pass rows' => TRUE, //this will ensure that the entire views row is passed as part of the context in your action callback. ), ); } 

The action callback is the following one.

function uploader_myaction($cmt, $context = array()) { drupal_set_message(t('uploader_myaction was called')); } 

When I try to add a field in the view fields, there is no Bulk operations: Content option.

2
  • Are you already using VBO? Commented Sep 9, 2013 at 22:35
  • I enabled vbo module. and "Bulk operations: Content" is visible for other views Commented Sep 9, 2013 at 22:49

2 Answers 2

1

I've had a similar problem. It's not ideal behaviour, but when I created the field, save it (selecting no action, or an action at random), then edit it (unselecting the random action, if I did that), then my custom action shows up.

0

You have to declare the hook_entity_info() because:

VBO only supports entity (base or revision) table Implement hook_entity_info() and make your table an entity. Use EntityAPIController so that you don't need to write other boilerplate functions.

Credit: bojanz

Issue: https://drupal.org/node/1282486

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.