Example: Batch API

Same name in other branches
  1. 3.x modules/batch_example/batch_example.module \batch_example
  2. 8.x-1.x batch_example/batch_example.module \batch_example
  3. 7.x-1.x batch_example/batch_example.module \batch_example
  4. 4.0.x modules/batch_example/batch_example.module \batch_example

Examples using batch API. (drupal 6)

2 'harmless' batches are defined : batch 1 : Load 100 times the node with the lowest nid batch 2 : Load all nodes, 20 times (uses a progressive op : load nodes by groups of 5)

The module defines the following pages :

  • /batch_example/example_1 : Simple form, lets you pick the batch that should be executed
  • /batch_example/example_2 : Multistep form : perform batch 1 and batch 2 as separate submission steps.
  • /batch_example/example_3 : No form - start a batch simply by clicking a link (not really user friendly, should probably be avoided)

This example is part of the Examples for Developers Project which you can download and experiment with here: http://drupal.org/project/examples

Parent topics

File

batch_example/batch_example.module, line 13

Functions

Title Sort descending File name Summary
batch_example_batch_1 batch_example/batch_example.module Batch 1 : Load 100 times the node with the lowest nid
batch_example_batch_2 batch_example/batch_example.module Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation)
batch_example_finished batch_example/batch_example.module Batch 'finished' callback used by both batch 1 and batch 2
batch_example_menu batch_example/batch_example.module Implementation of hook_menu().
batch_example_multistep_form batch_example/batch_example.module Multistep form
batch_example_multistep_form_submit batch_example/batch_example.module
batch_example_op_1 batch_example/batch_example.module Batch operation for batch 1 : load a node...
batch_example_op_2 batch_example/batch_example.module Batch operation for batch 2 : load all nodes, 5 by five
This is a multipart operation, using the
batch_example_page batch_example/batch_example.module
batch_example_simple_form batch_example/batch_example.module Test 1 :
Simple form
batch_example_simple_form_submit batch_example/batch_example.module Submit handler for the form 'batch_example_simple_form'.