Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Themes 2.2 how to clone a Moodle 2.2 theme: Difference between revisions

From MoodleDocs
No edit summary
(Replaced content with "{{obsolete}} This page text has been deleted because it contained inaccurate or out of date information. To see the previous text for this page, check the history.")
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Themes}}{{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 and soon to be announced Moodle 2.3.x it is important to understand that this tutorial is only valid for Moodle 2.2 themes.
{{obsolete}}


==Getting started==
This page text has been deleted because it contained inaccurate or out of date information. To see the previous text for this page, check the history.
 
Since this is a very easy introduction to creating a new Moodle theme, the first thing to create is a copy of the version of the theme you want to clone. For the purpose of this tutorial then, we will be cloning '''Afterburner''', which is a '''core''' theme.
 
== OK...let's get started. ==
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). 
 
If you open the '''mytheme''' directory you will find several directories, sub-directories and files within it.
 
These are:
; config.php :  Where all the theme configurations are made.
; lib.php :  Where all the functions for the themes settings are found.
; renderers.php :  Where all the renderers for this theme are found.
; settings.php :  Where all the setting for this theme are created.
; version.php :  Where the version number and plugin componant information is kept.
; /lang/ : This directory contains all language sub-directories for other languages if and when you want to add them.
; /lang/en/ : This sub-directory contains your language files, in this case ''English''.
; /lang/en/theme_afterburner.php : This file contains all the language strings for your theme. 
; /layout/ : This directory contains all the layout files for this theme.
; /layout/default.php : Layout file for front page.
; /layout/embedded.php : Layout file for embedded pages.
; /style/ : This directory contains all the CSS files for this theme.
; /pix/ : This directory contains a screen shot of this theme as well as a favicon and any images used in the theme.
; /pix_core/ :
; /pix_plugins/ :
 
==Renaming Elements==
 
The problem when '''cloning''' a theme is that you need to rename all those instances where the old theme name occures, 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
<code php>
$THEME->name = 'afterburner';
</code>
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.
 
=== Language Strings ===
 
When you open '''theme_mytheme.php''' the first thing you will see are the '''credits''' for the theme.
<code php>
/**
* 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
*/
</code>
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.
 
<code php>
$string['configtitle'] = 'Afterburner Custom Settings';
$string['pluginname'] = 'Afterburner';
$string['region-side-post'] = 'Right';
$string['region-side-pre'] = 'Left';
...
...
</code>
 
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.
 
<code php>
$string['choosereadme'] = 'My theme is a customised Moodle theme
based on the Moodle 2.2 Afterburner theme by Mary Evans.';
</code>
 
When you have finished all the changes in this file save it and close it.
 
Now that you know have had a chance to search for and change all the instances in the language file, checking the lib.php, settings.php and renderers.php you will be more familar for what you are looking for. 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...
 
{code}
/**
* 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)
{code}
 
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. instalation.
 
And basically that's it as far as this theme is concerned. If you are reading this and have run into problems, and need more help, then do please ask in the Themes Forum, [http://moodle.org/mod/forum/view.php?id=46] where you will find lots of help with your theme project.
--[[User:Mary Evans 2|Mary Evans 2]] 04:56, 7 April 2012 (WST)

Latest revision as of 08:02, 1 December 2016

Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.


This page text has been deleted because it contained inaccurate or out of date information. To see the previous text for this page, check the history.