1 -------------------------------------------------------------------------------
3 -------------------------------------------------------------------------------
5 -------------------------------------------------------------------------------
6 WARNING - PRELIMINARY DOCUMENTATION
7 This is designed to point new block developers in the right direction. At times
8 it may NOT be fully up-to-date with the source, or it may even contain some
9 tiny bit of misinformation that has slipped our notice. If you encounter such a
11 1. Use the existing block code as reference
12 2. Come to the moodle.org forums and tell the world! :) We 'll help you!
13 -------------------------------------------------------------------------------
15 You have to derive a class that extends MoodleBlock.
17 The derived class MUST:
19 * Implement a constructor that:
20 1. Sets $this->content_type (BLOCK_TYPE_LIST or BLOCK_TYPE_TEXT)
22 4. Sets $this->version
23 5. Sets $this->course equal to its only argument
25 The derived class MAY:
27 * Declare that the block has a configuration interface.
30 1. Define a method has_config() {return true;}
31 2. Define a method print_config() that prints whatever
32 configuration interface you want to have.
33 3. Define a method handle_config($data) that does what
34 is needed. $data comes straight from data_submitted().
36 * Limit the course formats it can be displayed in.
39 1. Define a method applicable_formats() which returns a bitwise
40 OR of one or more COURSE_FORMAT_XXX defined constants. These
41 are defined in lib/blocklib.php.
43 * Select a "preferred" width which the course format will try to honor.
46 1. Define a method preferred_width() which returns an integer.
47 This is the block's preferred width in pixels.
49 * Declare that the block is going to hide its header. This will result
50 in a more lightweight appearance. Ideal for announcements/notices.
53 1. Define a method hide_header() {return true;}