We will start our exploration of block plugins by revisiting a programming classic, Hello World.
Our first block will be about as simple a block as possible, simply displaying the text Hello World
.
Because our block will be called Hello World, let's start by creating a folder in the block
folder of our development site called helloworld
. Inside of this folder, create an empty PHP file called block_helloworld.php
. Note that the pattern is module-type_module-name.php
.
We start by creating a new class block_helloworld
that extends the block_base
class. Then we create a new init
function for this class. We set the two required values: the block title and the block version, as follows:
<?php class block_helloworld extends block_base { function init() { $this->title = get_string('helloworld', 'block_helloworld'); $this->version = 2009050700; }//function init