Example: Batch API

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

Functions & methods

NameDescription
batch_example_batch_1Batch 1 : Load 100 times the node with the lowest nid
batch_example_batch_2Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation)
batch_example_finishedBatch 'finished' callback used by both batch 1 and batch 2
batch_example_menuImplementation of hook_menu().
batch_example_multistep_formMultistep form
batch_example_multistep_form_submit
batch_example_op_1Batch operation for batch 1 : lode a node...
batch_example_op_2Batch operation for batch 2 : load all nodes, 5 by five This is a multipart operation, using the
batch_example_page
batch_example_simple_formTest 1 : Simple form
batch_example_simple_form_submit

examples/batch_example/batch_example.module, line 14