0

I have custom table in database {texts}
I used hook_views_data() for display this table using "VIEWS" HERE IS CODE:


    /**
      * 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;
    }

Now i want to create custom bulk operation on this table

I try this:


    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.
        ),
      );
    }

AND here is my action function


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

Problem is when i try to add field in my views fields. There is no option like
"Bulk operations: Content"

  • Are you already using VBO? – beth Sep 9 '13 at 22:35
  • I enabled vbo module. and "Bulk operations: Content" is visible for other views – Guno Sep 9 '13 at 22:49
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

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.