2011年1月26日 星期三

Create a new block

Assume the new block name is your_new_block:
  1. Got to moodle/blocks/
  2. Create a folder: your_new_block
  3. Copy blog_menu/*.* to your_new_block/ (as blog_menu is a simple block)
  4. Go to your_new_block folder
  5. Rename block_blog_menu.php to block_your_new_block.php
  6. Open block_your_new_block.php
  7. Remove the "require_once" line at the top
  8. Change "class block_blog_menu extends block_base {" to "class block_your_new_block extends block_base {"
  9. In init(), change "$this->title = get_string('pluginname', 'block_blog_menu');" to "$this->title = get_string('pluginname', 'block_your_new_block');"
  10. In get_content(), you can delete from "* Prepare the content for this block" to "// Return the content object", just keep the last return line.
  11. All you have to do is fill in $this->content->text = "Your block content html";
  12. Go to lang\en\ folder
  13. Rename block_blog_menu.php to block_your_new_block.php
  14. Open the file, change "$string['pluginname'] = 'Blog menu';" to your block displace name
  15. Notifications
  16. Done

沒有留言:

張貼留言