Project

General

Profile

HowTo create a custom Redmine theme » History » Version 10

Go MAEDA, 2018-01-08 00:38
Added directory structure

1 1 Jean-Philippe Lang
h1. HowTo create a custom Redmine theme
2
3 5 Jean-Philippe Lang
Redmine offers basic support for themes. Themes can override stylesheets (application.css) and add some custom javascript.
4 1 Jean-Philippe Lang
5
h2. Creating a new theme
6
7 4 Jean-Philippe Lang
Create a directory in @public/themes@. The directory name will be used as the theme name.
8 1 Jean-Philippe Lang
9
Example:
10
11
  public/themes/my_theme
12
13 4 Jean-Philippe Lang
Create your custom @application.css@ and save it in a subdirectory named @stylesheets@:
14 1 Jean-Philippe Lang
15
  public/themes/my_theme/stylesheets/application.css
16
17 2 Jean-Philippe Lang
Here is an example of a custom stylesheet that only override a few settings:
18 1 Jean-Philippe Lang
19 2 Jean-Philippe Lang
<pre><code>/* load the default Redmine stylesheet */
20
@import url(../../../stylesheets/application.css);
21 1 Jean-Philippe Lang
22 2 Jean-Philippe Lang
/* add a logo in the header */
23
#header {
24
    background: #507AAA url(../images/logo.png) no-repeat 2px;
25
    padding-left: 86px;
26
}
27
28 10 Go MAEDA
29 2 Jean-Philippe Lang
/* move the project menu to the right */
30
#main-menu { 
31
    left: auto;
32
    right: 0px;
33
}
34 1 Jean-Philippe Lang
</code></pre>
35
36 2 Jean-Philippe Lang
This example assume you have an image located at @my_theme/images/logo.png@.
37
38 1 Jean-Philippe Lang
You can download this sample theme as a starting point for your own theme. Extract it in the @public/themes@ directory.
39
40 5 Jean-Philippe Lang
h2. Adding custom javascript
41
42
Simply put your javascript in @javascripts/theme.js@ and it will automatically be loaded on each page  (Redmine >= 1.1.0 only).
43
44 8 Bernd Kosmahl
h2. Setting a Favicon
45
46 9 Go MAEDA
Put your favicon in @favicon@ directory and it will automatically be loaded instead of default one on each page. The name of the favicon file can be anything.
47 8 Bernd Kosmahl
48 1 Jean-Philippe Lang
h2. Applying the theme
49
50
Go to "Administration -> Settings" and select your newly created theme in the "Theme" drop-down list. Save your settings.
51
Redmine should now be displayed using your custom theme.
52 2 Jean-Philippe Lang
53 5 Jean-Philippe Lang
If you are using Redmine < 1.1.0, you may need to restart the application so that it shows up in the list of available themes.
54 10 Go MAEDA
55
h2. Directory structure of themes
56
57
A theme consists of the following files:
58
59
* @favicon/<favicon file>@ (optional): favicon for the theme
60
* @javascripts/theme.js@ (optional): custom JavaScript for the theme
61
* @stylesheets/application.css@ (required): CSS for the theme
62
63
64
<pre>
65
public/
66
  +- themes/
67
       +- <theme name>/
68
            |
69
            +- favicon/
70
            |    +- <favicon file> (e.g. favicon.ico, favicon.png)
71
            |
72
            +- javascripts/
73
            |    +- theme.js
74
            |
75
            +- stylesheets/
76
                 +- application.css
77
</pre>