Themes 2.2 how to clone a Moodle 2.2 theme
Moodle 2.2 This document describes how to clone Afterburner theme so that you can build on this to create a theme of your own. It assumes you have some understanding of how themes work within Moodle 2.2, as well as a basic understanding of HTML and CSS. Also, because of the rapid development within Moodle, resulting in a number of versions available namely 2.0.x, 2.1.x, 2.2.x, 2.3.x and soon to be announced Moodle 2.4.x, it is important to understand that this tutorial is only valid for Moodle 2.2 and 2.3 themes. For more recent themes based on Clean and More, please check out the README.txt  file contained in the Clean folder.
From your Moodle theme directory right click on afterburner and then copy and paste back into your Moodle theme directory. You should now have a folder called Copy of afterburner. If you right click this folder you are given the option to Rename it. So rename this folder to mytheme (or to whatever name you want to call your cloned theme). It is important to use only lower case letters and underscores.
If you open the mytheme directory you will find several directories, sub-directories and files within it.
- Where all the theme configurations are made.
- Where all the functions for the themes settings are found.
- Where all the renderers for this theme are found.
- Where all the setting for this theme are created.
- Where the version number and plugin componant information is kept.
- This directory contains all language sub-directories for other languages if and when you want to add them.
- This sub-directory contains your language files, in this case English.
- This file contains all the language strings for your theme.
- This directory contains all the layout files for this theme.
- Layout file for front page and general pages combined.
- Layout file for embedded pages.
- This directory contains all the CSS files for this theme.
- This directory contains a screen shot of this theme as well as a favicon and any images used in the theme.
The problem when cloning a theme is that you need to rename all those instances where the old theme name occurs, in this case afterburner. The first place to look is config.php, where you you need to define the name of your theme. So change
$THEME->name = 'afterburner';
to the name of your new theme.
You will need to change the name of lang/en/theme_afterburner.php. This file, as well as needing to be renamed, also needs some of its content renaming too. So before you forget, right click on this file and rename it to the name of your new theme before you open it.
When you open theme_mytheme.php the first thing you will see are the credits for the theme.
/** * Strings for component 'theme_afterburner', language 'en' * * @package theme_afterburner * @copyright 2011 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */
Here you will need to change the reference from afterburner to mytheme, you can leave the rest of this as it is.
The next things you will find in this file are what are known as the language strings. These are all the customised words or phrases used in this theme.
$string['configtitle'] = 'Afterburner Custom Settings'; $string['pluginname'] = 'Afterburner'; $string['region-side-post'] = 'Right'; $string['region-side-pre'] = 'Left'; ... ...
In the $string section above, you will need to change ALL instances of the old theme name Afterburner to your new theme name. In this next section alone you will find seven instances of the name Afterburner to rename.
The only section you may want to change completely is the choosereadme. You could write something like this instead.
$string['choosereadme'] = 'My theme is a customised Moodle theme based on the Moodle 2.2 Afterburner theme by Mary Evans.';
When you have finished all the changes in this file save it and close it.
Now that you have had a chance to search for and change all the instances in the language file, you will be more familiar for what you are looking for when you begin the mamoth task of going through the files associated with the Custom Settings for the Afterburner theme. There are three files to check through. These are...
But do be sure to rename ALL the instances in these three files, as there are quite a number of them.
The last file to change is version.php, here you will find the following...
/** * Theme version info * * @package theme * @subpackage afterburner * @copyright 2011 Mary Evans * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; $plugin->version = 2011082400; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2011081700; // Requires this Moodle version $plugin->component = 'theme_afterburner'; // Full name of the plugin (used for diagnostics)
Just as long as you change the instance of afterburner to your new theme's name you will be almost ready to try out this theme in your Moodle 2.2. installation.
If you want this theme to use the same CSS rules from the Afterburner theme, then you need to make one more change to your new theme's config.php file.
First you will need to ADD afterburner to the parent theme array like this...
$THEME->parents = array('afterburner', 'base');
Next you can delete all these style sheets from this list bar one file...that is afterburner_settings.css. This is important as your theme will need to rely on this stylesheet for your custom settings. So delete this list...
$THEME->sheets = array( 'afterburner_layout', /** Must come first: Page layout **/ 'afterburner_styles', /** Must come second: default styles **/ 'afterburner_menu', 'afterburner_blocks', 'afterburner_mod', 'afterburner_calendar', 'afterburner_dock', 'afterburner_settings', 'rtl' );
but leave afterburner_settings.css which you could just rename to settings.css.
$THEME->sheets = array('settings');
You will then be able to delete all the stylesheets from your new theme's style directory leaving just editor.css and afterburner_settings.css which you will also need to rename to settings.css.
So whenever you need to change the CSS for your new theme, you can do this in your theme's settings page, by going to Site Administration > Appearance > Themes > and choose your new theme from those names listed.
Cut to the chase
Patience is a virtue! :)
If you have only just got here and not read the above Tutorial then you have missed the best part. If on the other hand you have finished this tutorial, then please let me have some feedback.
If after reading this you run into problems, and need more help, then do please ask in the Themes Forum,  where you will find lots of help with your new theme project.
--Mary Evans 2 06:03, 7 April 2012 (WST)