zoukankan      html  css  js  c++  java
  • drupal7 Views Bulk Operations (VBO)

    介绍

    drupal通常用views制作列表,列表也应该能实现某些操作,例如删除、审批等,并且应该是批量进行的,VBO的存在就是为了实现views批量操作功能。事实上,drupal把操作统称为action,而VBO的原理仅仅是把views与action关联起来。

    使用步骤(来源于官方)

    1. Create a View.
    2. Add a "Bulk operations" field if available
    3. Configure the field. There's a "Views Bulk Operations" fieldset where the actions visible to the user are selected.
    4. Go to the View page. VBO functionality should be present.

    给VBO添加更多的操作

    由于VBO的操作实现依赖于action,所以声明新的action就等于为VBO添加新的操作。
    假设开发一个delete node的action,mymodule.module代码大致如下:

    /**
     * Implementation of hook_action_info().
     */
    function mymodule_action_info() {
      return array(
          'mymodule_node_delete_action' => array(
              'label' => t('Delete node'),
              'type' => 'node', // 限定的内容类型
              'aggregate' => TRUE, // 如果为TRUE,即为批量操作
              'configurable' => FALSE,
              'triggers' => array('any'), // 触发器限定
          ),
      );
    }
    
    /**
     * Implementation of a Drupal action.
     * Passes selected ids as arguments to a view.
     */
    function mymodule_node_delete_action($entities, $context = array()) {
      $nids = array_keys($entities);
      node_delete_multiple($nids);
    }

    然后在views中的"Bulk operations" field就可以看到delete node这个action。

  • 相关阅读:
    HTTP 与 HTTPS 的区别
    cookie 和session 的区别详解
    IntelliJ远程调试教程
    selenium 自动化测试面试题及答案
    性能测试总结(一)---基础理论篇(转载)
    性能测试总结(二)---测试流程篇(转载)
    性能测试总结(三)--工具选型篇
    eclipse调试的基本意义
    控制反转(IOC)和依赖注入(DI)
    前端框架layui
  • 原文地址:https://www.cnblogs.com/catcat811/p/3329312.html
Copyright © 2011-2022 走看看