The easiest example for me to work with is one of my own blocks - the lesson objective block: https://github.com/davosmith/moodle-objectives
The slight added complexity with this block is that I have created a 'lib.php' file that holds most of the code for the block (inside a block_objectives_class class), to try and keep it all neat and tidy. Essentially all the other PHP files do a little setting up, then call code in my lib.php file. With that in mind, I'll talk you through a few sections:
block_objectives.php - function get_content();
This calls my 'get_block_text' function, which, amongst other things, outputs an HTML link to 'block/objectives/edit.php' (teachers only) and 'block/objectives/view.php'.
If you now look inside view.php ( https://github.com/davosmith/moodle-objectives/blob/master/view.php ), this:
- includes the main Moodle config.php file (which gives access to all the standard Moodle function calls)
- gets the parameters passed to it (via required_param / optional_param)
- checks the paramaters (mostly via $DB->get_record calls)
- calls $PAGE->set_url() to define the correct URL for accessing the page (essential)
- calls require_login() to make sure the user is logged in and that the $USER global variable is set up (amongst other things)
- It then passes control to my lib.php file
- use 'has_capability' to check the user is allowed to view the objectives (redirecting back to the course page if not)
- set up lots of data structures that are only relevant to my particular plugin
- use '$PAGE->set_title', '$PAGE->set_heading' and 'echo $OUTPUT->header()' to start the page off (this is hidden inside a separate function call, as I need the same title for several pages in my plugin).
- I then output all the content for the page (again, this is plugin-specific)
- Finally I call 'echo $OUTPUT->footer()' to finish off the page
I hope that is a good enough summary to get you started.
If you are creating this as a block, then it should go in the 'blocks/[name of your block]' folder, and you probably want to read through the documentation for the rest of the details (
http://docs.moodle.org/dev/Blocks )