Extensive Blocks documentation now available

Extensive Blocks documentation now available

by John Papaioannou -
Number of replies: 13
  • Did you ever want to develop a block but were afraid to ask?
  • Do you have a block that works with Moodle 1.4 and want to update it for 1.5?
  • Are you curious to see what Moodle 1.5 can do for blocks?
  • Do you enjoy reading lengthy guides written by hopelessly sleepy programmers who try to make the reading light and make things worse?

If the answer to any of the above is a thunderous YES! (ok, well, even a squeaky one will do...) then the new Blocks Documentation is ideal for you!

You can fetch it from CVS (/blocks/HOWTO.html), and for those who believe that every informative post has to have at least one link to some really useful resource, you can try this one. big grin

Jon

PS: It still needs polishing and some sections should have more "meat". But what person did ever wait for the official release version? wink
Average of ratings: -
In reply to John Papaioannou

Re: Extensive Blocks documentation now available

by Bryan Williams -
Excellent Jon! I have created a PDF file of your documentation and added it to the Moodle Documentation Project course.
In reply to Bryan Williams

Re: Extensive Blocks documentation now available

by Chardelle Busch -
Picture of Core developers

Nice new pictures guys tongueout!

Thanks for your hard work Jon.  I was wondering if you have figured out a good way (or place) for developers to let us know about their blocks (like your fantastic private messages block), and since it appears that they need to be updated for 1.5, letting us know if they've updated and what Moodle versions their blocks work with, etc.  Things like this tend to get lost in forums like the Blocks forum.  Maybe by adding a section to the Moodle Add-ons page for blocks thoughtful? Or maybe a glossary for blocks (less work for you maintain)?

Thanks,

Chardelle

In reply to Chardelle Busch

Re: Where to store the blocks?

by John Papaioannou -
Chardelle, I don't want to spoil the fun, but someone, somewhere, is preparing something for you... wink
In reply to John Papaioannou

Moodle: a new Sculls & Bones Fraternity?

by Ger Tielemans -

Is Moodle becoming a kind of Sculls & Bones Fraternity?
(Working in secret on version 2 and now this..)

Is this a good choice, to keep the information away from the critical users? To protect these users? Is that what you call Social Constr.. and wise if you know your Classics? (An analysis: drifting away by small group thinking: Kennedy and the causes for the invasion of the Bay of Pigs / Cuba)
_

By the way, a fantastic step forward for Moodle: for the first time a readable technical document about a not so simple part of moodle (create your own blocks) instead of the normal answer: "the doc is in the code" , thanks thanks thanks, this will solve most of my sorrows about grading-up from my patched, cripled but still working version 1.3.?? with 2068 users to 1.4.2, 1.4.3, 1.5 and 2.1!! (I will skip version 2.0)

In reply to Bryan Williams

Re: Extensive Blocks documentation now available

by Jacob Romeyn -

Hi Bryan

I the PDF file some of the code has been cut off.  page 4, 5  etc.sad

Jacob

In reply to Jacob Romeyn

Re: Extensive Blocks documentation now available

by Bryan Williams -
Hi Jacob,

I'm not seeing this. I just double checked these pages and it appears everything is there. Looks like some information was carried over to the top of the next page. Is this a scrolling issue?  Do others see missing information?

Bryan
In reply to Bryan Williams

Re: Extensive Blocks documentation now available

by John Papaioannou -
Bryan, yes, I saw it too (from one machine, at least). Parts of the code blocks are getting out of the page. But please don't rush to try to fix it somehow, I know that this can be at least improved from the HTML source. The guide is going to be receiving lots of small refinements in the near future, so there's no point in re-PDFing it every little while.
In reply to John Papaioannou

Re: Extensive Blocks documentation now available

by Tony Hursh -
Thanks, Jon. That answers a lot of questions!

In reply to John Papaioannou

Re: Extensive Blocks documentation now available

by Jacob Romeyn -
Thank you for the blocks manual, looks very simple but:
When I placed this php file below in the /moodle/blocks/simpehtml   directory and got the following error when I went to the admin:
<?php
class CourseBlock_simplehtml extends MoodleBlock {
    function init() {
        $this->title = get_string('simplehtml', 'block_simplehtml');
        $this->content_type = BLOCK_TYPE_TEXT;
        $this->version = 2004111200;
    }
}
function get_content() {
    if ($this->content !== NULL) {
        return $this->content;
    }

    $this->content = new stdClass;
    $this->content->text = 'The content of our SimpleHTML block!';
    $this->content->footer = 'Footer here...';

    return $this->content;
}
?>
In reply to Jacob Romeyn

Re: Extensive Blocks documentation now available

by John Papaioannou -
Argh!

This got me terrified before I figured it out...

Look at your function init(). After the code, there are two closing braces ( } ). One of them is for the function itself. Now the other one, considering where it is, applies to the class itself. So the function get_content(), which is defined afterwards, is actually NOT a part of your class!

What you need to do is move the second of the two braces just before the final ?> line, and of course add all methods inside of that brace.

This should probably be made a bit more clear in the docs. Thanks!

Jon
In reply to John Papaioannou

Re: Extensive Blocks documentation now available

by Jacob Romeyn -

Thank you Jonsmile

That fixed it, I better learn a little more PHP programming so that can see the errors myselfblush

The ability to make blocks for inexperienced programmers, like me,  is fantastic.big grin  A great function.approve