In mod_form.php, add this line:
$this->_features->groupings = true;
Note: But i still wonder why others module don't add this line but they are still available for groupING, any idea?
2011年3月10日 星期四
2011年3月8日 星期二
Add a table to Module Database
- Site administration -> Development -> XMLDB editor
- Find your module and click [Load]
- Click [Edit]
- Click [New table] and fill in the detail
- Click [Back]
- Click [View PHP code]
- Select action: create table
- Select table: select your table name
- Click "View"
- Copy the code to mod/your_mod/db/upgrade.php
- Change XXXXXXXXXX to new version number (e.g. 2011022301)
- Open mod/your_mod/version.php, change $module->version to the new version number
- Notification
- Done
2011年2月22日 星期二
Add a field to Module Update page
By Module Update page, i mean the page shown when you add a new activity or update it.
Note: You should add a field to the database first if you want to save the entered field information.
Note2: your_field is the field name in the database of table mdl_your_mod, the field information will save to the table
Note3: To show the field, just use $your_mod->your_field
Note: You should add a field to the database first if you want to save the entered field information.
- Open mod\your_mod\mod_form.php
- Add this line: $mform->addElement('text', 'your_field', 'label_shown', array('size'=>'64'));
- Done
Note2: your_field is the field name in the database of table mdl_your_mod, the field information will save to the table
Note3: To show the field, just use $your_mod->your_field
Add a field to Module Database
- Site administration -> Development -> XMLDB editor
- Find your module and click [Load]
- Click [Edit]
- At the Tables section, click the table you want to add field
- Click [New field] and fill in the detail
- [View PHP code]
- Select action: add field
- Select field/key/index: your_new_field_name
- Click "View"
- Copy the code to mod/your_mod/db/upgrade.php
- Change XXXXXXXXXX to new version number (e.g. 2011022301)
- Open mod/your_mod/version.php, change $module->version to the new version number
- Notification
- Done
Remove a Module
- Goto: Site administration -> Plugins -> Activity modules -> Manage activities
- Find your module and click Delete
- Remove the module from mod/ folder
- Done
2011年1月24日 星期一
Build a Hello World new module
- Download the NEWMODULE.zip (HEAD) from http://docs.moodle.org/en/Development:NEWMODULE_Documentation (or download here) (Follow the README.txt from the zip file! (not the tutorial at moodle.org, it is not for 2.0))
- Rename all occurrences of "NEWMODULE" to "widget" (or your new module name) of the all files in the zip (161 replacements) (Also rename "newmodule" to "widget" for unix system)
- Rename "NEWMODULE" folder to "widget"
- Rename lang\en\NEWMODULE.php to widget.php
- In version.php, modify $module->version to current date (you need to change the XX for each update). Comment this line: $module->version = 0
- Optional: In view.php, just before the footer(), add -> echo 'Hello World';
- Copy the widget folder to moodle\mod\
- Site Administration -> Notifications, when you see the new module, -> Update
- Done.
訂閱:
文章 (Atom)