[HOW-TO] Add 2.4 course format callbacks

[HOW-TO] Add 2.4 course format callbacks

by Danny Wahl -
Number of replies: 1

Hi all, if you look at the pull-request commit for MDL-26048 you'll see how to add course format callbacks to a 2.4 theme - which is easy.

What I want to show you is how to add the 2.4 callbacks for ALL themes, it's pretty easy, we just use the same method_exists() check that we use with 2.1 vs. 2.2 for main_content()

see it at github (look at header.php)

basically it does this: checks to see if Moodle "knows" about various output objects, if it does, it stores them to a variable, if it doesn't - then it stores NULL to the variable, then later outputs whatever's in the variable.

Now you don't need to store different branches in your theme or drop development support for different versions of Moodle.

Average of ratings:Useful (1)
In reply to Danny Wahl

Re: [HOW-TO] Add 2.4 course format callbacks

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

Hi Danny - thanks for that. Will add it to krystle before I release it (hopefully later today)

One thing - I think the tracker reference should be MDL-36048 smile

Rich