Note:

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

Talk:Blocks: Difference between revisions

From MoodleDocs
mNo edit summary
(Removing Roel's update for Moodle 2.0 - this is now part of the main tutorial)
Line 1: Line 1:
{{Moodle 2.0}}
{{Moodle 2.0}}
== The Specialists ==
To customize the block's title under Moodle 2.0 the following code can be used:
edit_form.php
<code 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);
</code>
simplehtml/lang/en/block_simplehtml.php
<code php>
  $string['configtitle'] = 'Title of simple html';
</code>
block_simplehtml.php
<code php>
  function specialization() {
    $this->title = isset($this->config->title) ? format_string($this->config->title) : format_string(get_string('simplehtml', 'block_simplehtml'));
    }
</code>
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.
--[[User:Roel Cantada|Roel Cantada]] 11:43, 7 July 2011 (WST)

Revision as of 11:25, 29 July 2011

Moodle 2.0