-
Notifications
You must be signed in to change notification settings - Fork 3
/
themes.gtw
77 lines (49 loc) · 2.42 KB
/
themes.gtw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
~~LANG:FR@frman:themes~~
Jelix offers a theme system, so you can rewrite some templates to ease
the design for CSS, without modifying original files.
===== Theme and templates =====
Templates for theme must be located in the @@F@app/themes/@@ application folder.
Each template related to a module must be under a sub-directory named like its
module.
Say you want to adapt @@F@main.tpl@@ template of "**example**" module for "**web20**"
theme. You'll stored @@F@main.tpl@@ in @@F@app/themes/web20/example/@@. Note:
original and theme template have the same name.
Default theme is originally named "default". If you want to just overload a
template, you will store it under @@F@app/themes/default/module_name/template_name.tpl@@.
Templates of a theme can also be stored into @@F@var/themes/@@. But it should
be only templates created by the application itself or an other process,
during the life of the application.
A module can also provide its templates for some specific themes.
Templates should then be stored into its directory @@templates/themes/theme_name/@@
===== Theme and design files =====
Here design files means CSS, graphics, JS files. Those files must be accessible
from web request sand therefore shall be located in @@F@www/themes/<theme_name>@@
application folder.
In your scripts, to retrieve your //theme// path, use:
<code php>
$themePath = jApp::urlBasePath().'themes/'.jApp::config()->theme.'/';
$rep->addCssLink($themePath.'design.css');
</code>
In a template, to add a css resource, use:
<code html>
{meta_html csstheme 'design.css'}
</code>
Or more directly, @@$j_themepath@@ variable gives access to your theme path in
a template:
<code html>
<img src="{$j_themepath}logo.png" alt="logo"/>
</code>
===== Selecting a default theme =====
@@theme@@ parameter of [[/configuration/configuration-files#generic-section|configuration]] file fills this functionnality.
<code ini>
theme = web20
</code>
===== Selecting theme dynamically =====
A typical use case is to let the user select his theme in a list. Suppose there
is a form with a list of theme and the user picks one of them then submit.
Application stores its choice (using session or a specific cookie).
Each time the user will visit the application, it will select his theme like this :
<code php>
jApp::config()->theme = $choosenTheme;
</code>
Of course the best place to do it is in a [[/plugins/coord|coordinator plugin]] that must be coded and plugged.