Talk:Blocks
From MoodleDocs
Moodle 2.0
The Specialists
To customize the block's title under Moodle 2.0 the following code can be used:
edit_form.php
$mform->addElement('text', 'config_title', get_string('configtitle', 'block_simplehtml'));
$mform->setDefault('config_title', get_string('simplehtml', 'block_simplehtml'));
$mform->setType('config_title', PARAM_MULTILANG);
simplehtml/lang/en/block_simplehtml.php
$string['configtitle'] = 'Title of simple html';
block_simplehtml.php
function specialization() {
$this->title = isset($this->config->title) ? format_string($this->config->title) : format_string(get_string('simplehtml', 'block_simplehtml'));
}
The specialization function is copied from the html block. Different standard blocks seem to implement this differently. It would be nice if someone can explain what's happening in this specialization function.
--Roel Cantada 11:43, 7 July 2011 (WST)