Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Talk:Blocks

From MoodleDocs
Revision as of 03:43, 7 July 2011 by Roel Cantada (talk | contribs) (moodle 2 code for customizing block's title)

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_text', 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)