Note: You are currently viewing documentation for Moodle 2.6. Up-to-date documentation for the latest stable version of Moodle may be available here: NEWMODULE Tutorial.

Development:NEWMODULE Tutorial: Difference between revisions

From MoodleDocs
Line 10: Line 10:




== Some basic regulation for the beginning php developer ==
== Some basic regulation for the beginner php developer ==
You will probably want to use this set of basic commands
You will probably want to use this set of basic commands
*require
*require

Revision as of 13:51, 28 March 2008

How to begin the creation of a new module.

  • choose a name for your module. Take care: no capital letter and no numbers in the name. In this example it will be choosen: "widget"
  • find/replace all the occorrences of newmodule in each file with the name of your own module
  • change the name of the folder containing you new created module to "widget"
  • change the name of the file in widget/lang/en_utf8/newmodule.php to "widget.php"
  • put your just born widget folder in moodle/mod
  • visit "notification" page of moodle->Site Administration block
  • follow the instruction on the screen


Some basic regulation for the beginner php developer

You will probably want to use this set of basic commands

  • require
  • require_once
  • include
  • include_once

Take in mind the difference between them.
The difference between require and require_once is: ???
The difference between include and include_once is: ???
Use only xxx to call libraries and use only xxx to include snippets of code written to different files.
Remember:

  • redirect move the execution of the code to the target file and you are allowed to call the target file passing it some parameters.

for instance: redirect("./come_modello/edit.php?id=$cm->id");

  • include requires the name of the called file "clean", without "?id=$cm->id", for instance, and the target file is executed as it were written in the place of the calling row.


You need these two informations to correctly include library files into target files called through redirect or include.