Tiny hack to make $course work OK in file resources (print_header)
[moodle.git] / blocks / README.txt
blob6a848082d18dd006137d5f8f3faf4b488b6e4a26
1 -------------------------------------------------------------------------------
2 CREATING NEW BLOCKS
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
10 case, please:
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)
21         3. Sets $this->title
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.
28       To do so:
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.
37       To do so:
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.
44       To do so:
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.
51       To do so:
53         1. Define a method hide_header() {return true;}