Note:

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

Talk:Creating a theme

From MoodleDocs

Wow! Is the code for this theme available in a file, say in Modules and Plugins? Or did I miss it in my quick look. I can see my next project at work. --Chris collman 12:07, 6 April 2010 (UTC)

Hi Chris, the code in this tutorial isn't available anywhere the reason being that it is entirely based on the base theme :) check out theme/base/* you'll notice that what is in there is very close to the code I wrote for this tutorial. --Sam Hemelryk 01:33, 7 April 2010 (UTC)

Hi Sam, I did not look, why get confused by reality and numb about :) I sort of got here by creating a 1.9.8 localhost that I could do screenshots for Standard themes and then tried my first complete install package of 2.0 in 3 months. My primary goal is to revamp the 'navigation' and organization of Category:Themes pages, your instructions are going to help me. Thanks for all your time and efforts. --Chris collman 11:26, 7 April 2010 (UTC)

Good crisp documentation!! Thank you Sam for this :) You ve made our lives easier with 2.0 themes!! ;)

Cheers!! --Navin Dutta 03:12, 13 April 2010 (UTC)

Question about instruction

Sam, your instructions say there will only be one layout php file called standard.php. What is the general.php file pointer doing in config.php under base? If I understand things, it should be pointed to the theme base (which has a general.php) or the file should be called standard.php. Is that correct?

It is snowing, so I thought I would see if I could follow your instructions and do something like standardlogo in 1.9 for fun. No doubt will crash and burn with this part time project over the next 2 years :) Thanks --Chris collman 13:12, 16 April 2010 (UTC)

Broken :-(

Hello,

Thanks for the tutorial, but with - Moodle 2.0 Preview 2 (Build: 20100531) - I get the error 'Coding error detected, it must be fixed by a programmer: Trying to reference an unknown block region side-post' when trying to select the theme for modern browsers.

Update: I've made the changes required to solve the problem after reading: http://moodle.org/mod/forum/discuss.php?d=150190

Cheers,

Gareth

Layouts

The need for the layout definitions is mentioned but not what they or what they do. This either needs explained or a link to where it is explained. It certainly isn't obvious --Howard Miller 17:18, 12 July 2010 (UTC)

Is this what???

Sorry guys, I think this is confusing Please understand that I am not that technically literate so I need things said a lot clearer:

config.php

   All of our settings will go here. 

/style/

   This directory will contain all of our stylesheets. 

/style/excitement.css

   All of our css will go in here. 

/pix/

   Into this directory we'll put a screen shot of our theme as well as our favicon and any images we use in CSS. 

/layout/

   Our layout files will end up in this directory. 

/layout/standard.php

   This will be our one basic layout file. 

There is a clear difference between a file and a directory - but the manner in which the above example is set up does not appear to make that distinction. Could it not be better put like:

Create the theme directory/folder, which we are calling "excitement". Into that directory/folder we create a file:

 config.php 
   All of our settings will go here.

Then we create the directories/folders

 /style/  
     This directory/folder will contain all of our stylesheets. 
 /pix/ 
     Into this directory/folder we'll put a screen shot of our theme as well as our favicon and any images we use in CSS. 
 /layout/ 
     Our layout files will end up in this directory/folder. 

Into the style directory/folder we create a file:

excitement.css 
   Where we place All of our css rules. 

And in the layout directory/folder we create a file:

 standard.php 
   This will be our one basic layout file. 

For me, not being that smart, this is a far more easily understood structure than has been shown.

Configuring Our Theme

The DIV that contains the config.php code had a vertical scrollbar. This is because the DIV around the code had a height of 400. This is fine when you are reading this document on the computer, but when you print it a large part of the php ($THEME->layouts = array) is chopped off. I increased the DIV height to 1780 and it solves the printing problem. Is this ok?

--Luis de Vasconcelos 15:54, 2 November 2010 (UTC)

Quick start guide: extend another theme

Update: there is currently an issue with sub theme, that broke theme sometimes. At the moment extending Arialist theme results in a broken theme and extending Fusion works.

I'm writing this draft section on the fly. I'll integrate it later to the documentation. I had some difficulties to find a skeleton code to extend arialist theme. Here are the steps to extend it:
1- Create a folder /theme/newtheme
2- Create a file /theme/newtheme/config.php

//the theme name
$THEME->name = 'newtheme';

//You are going to declare that the parent theme is arialist. 
//For this, you will need to know the $THEME->parents of arialist. 
//Two important things:
//a- you need to include all parent themes of the parent theme (and all parents of the parents of the parent...). 
//b- the array element order is very important. You can see here that 'arialist' is the first element. 
//It means that the 'arialist' css will be checked first, then the 'canvas' css, finally the 'base' css. 
//This rules applies to css, layout, lang...
$THEME->parents = array('arialist', 'canvas', 'base');

3- Create a lang file /theme/lang/en/theme_newtheme.php

$string['pluginname']='New theme';
$string['choosereadme']='This theme extends Arialist theme. More information...';

4- In Moodle, select the new theme. It should have the appearance of Arialist.

--Jerome mouneyrac 11:52, 4 January 2011 (+8, Perth)

Theme names must not contain a minus character (moodle 2.1)

I tried to generate theme settings for my new theme.

The name became important.

new-theme <- does not work, error: Default exception handler: Ung\xc3\xbcltige Admin-Einstellungen (theme_new-theme/backgroundcolor) Debug: \n* line 1436 of /lib/adminlib.php: m....

newtheme <- works

Not working

I'm using Moodle 2.5, and I've used the instructions to create my new theme. The theme shows up in Theme Selection, but it's not pulling my CSS in for some reason. It continues to use the Base.