You are here

Example: Batch API in Examples for Developers 6

Same name and namespace in other branches
  1. 8 batch_example/batch_example.module \batch_example
  2. 7 batch_example/batch_example.module \batch_example
  3. 3.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
This is an example outlining how a module can define batches.

Functions

Namesort descending Location Description
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'.