none
[openafs-wiki.git] / TWiki / TWikiSkins.mdwn
1 <div>
2   <ul>
3     <li><a href="#TWiki Skins"> TWiki Skins</a><ul>
4         <li><a href="#Overview"> Overview</a></li>
5         <li><a href="#Defining Skins"> Defining Skins</a></li>
6         <li><a href="#Variables in Skins"> Variables in Skins</a><ul>
7             <li><a href="#The "Go" Box and Navigation Box"> The "Go" Box and Navigation Box</a></li>
8           </ul>
9         </li>
10         <li><a href="#Using Cascading Style Sheets"> Using Cascading Style Sheets</a></li>
11         <li><a href="#Packaging and Publishing Skins"> Packaging and Publishing Skins</a></li>
12         <li><a href="#Activating Skins"> Activating Skins</a></li>
13       </ul>
14     </li>
15   </ul>
16 </div>
17
18 # <a name="TWiki Skins"></a> TWiki Skins
19
20 _Skins overlay regular templates with alternate header/footer layouts; topic text is not affected_
21
22 ## <a name="Overview"></a> Overview
23
24 Skins are customized [[TWikiTemplates]] files. You can use skins to change the look of a %WIKITOOLNAME% topic, for example, the layout of the header and footer. Rendered text between header and footer does **_not_** change. You can also use skins to define an alternate view, like a view optimized for printing.
25
26 ## <a name="Defining Skins"></a> Defining Skins
27
28 Skin files are located in the `twiki/templates` directory and are named with the syntax: <code>**&lt;scriptname&gt;.&lt;skin&gt;.tmpl**</code>. For example, the **Printable** skin for the `view` template is `view.print.tmpl`.
29
30 Use the existing [[TWikiTemplates]] (like `view.tmpl`) or skin files as a base for your own skin, name it for example `view.myskin.tmpl`.
31
32 ## <a name="Variables in Skins"></a> Variables in Skins
33
34 You can use [[template variables|Main/TWikiTemplates#TemplateVariables]], [[TWikiVariables]], and other predefined variables to compose your skins. Some commonly used variables in skins:
35
36 <table border="1" cellpadding="0" cellspacing="0">
37   <tr>
38     <th bgcolor="#99CCCC"><strong> Variable: </strong></th>
39     <th bgcolor="#99CCCC"><strong> Expanded to: </strong></th>
40   </tr>
41   <tr>
42     <td><code>%WIKILOGOURL%</code></td>
43     <td> Link of page logo </td>
44   </tr>
45   <tr>
46     <td><code>%WIKILOGOIMG%</code></td>
47     <td> Image URL of page logo </td>
48   </tr>
49   <tr>
50     <td><code>%WIKILOGOALT%</code></td>
51     <td> Alt text of page logo </td>
52   </tr>
53   <tr>
54     <td><code>%WEBBGCOLOR%</code></td>
55     <td> Web specific background color, defined in the [[Main/WebPreferences]]</td>
56   </tr>
57   <tr>
58     <td><code>%WIKITOOLNAME%</code></td>
59     <td> The name of your TWiki site </td>
60   </tr>
61   <tr>
62     <td><code>%SCRIPTURL%</code></td>
63     <td> The script URL of TWiki </td>
64   </tr>
65   <tr>
66     <td><code>%SCRIPTSUFFIX%</code></td>
67     <td> The script suffix, ex: <code>.pl</code>, <code>.cgi</code></td>
68   </tr>
69   <tr>
70     <td><code>%WEB%</code></td>
71     <td> The name of the current web. <strong><em>Note:</em></strong> It is recommended to URL-encode the variable in form actions with <code>%INTURLENCODE{"%WEB%"}%</code> for proper handling in an internationalized environment </td>
72   </tr>
73   <tr>
74     <td><code>%TOPIC%</code></td>
75     <td> The name of the current topic. <strong><em>Note:</em></strong> It is recommended to URL-encode the variable in form actions with <code>%INTURLENCODE{"%TOPIC%"}%</code> for proper handling in an internationalized environment </td>
76   </tr>
77   <tr>
78     <td><code>%WEBTOPICLIST%</code></td>
79     <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
80   </tr>
81   <tr>
82     <td><code>%TEXT%</code></td>
83     <td> The topic text, e.g. the content that can be edited </td>
84   </tr>
85   <tr>
86     <td><code>%META{"form"}%</code></td>
87     <td>[[Main/TWikiForms]], if any </td>
88   </tr>
89   <tr>
90     <td><code>%META{"attachments"}%</code></td>
91     <td>[[Main/FileAttachment]] table </td>
92   </tr>
93   <tr>
94     <td><code>%META{"parent"}%</code></td>
95     <td> The topic parent </td>
96   </tr>
97   <tr>
98     <td><code>%EDITTOPIC%</code></td>
99     <td> Edit link </td>
100   </tr>
101   <tr>
102     <td><code>%REVTITLE%</code></td>
103     <td> The revision title, if any, ex: <code>(r1.6)</code></td>
104   </tr>
105   <tr>
106     <td><code>%REVINFO%</code></td>
107     <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
108   </tr>
109   <tr>
110     <td><code>%WEBCOPYRIGHT%</code></td>
111     <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
112   </tr>
113   <tr>
114     <td><code>%BROADCASTMESSAGE%</code></td>
115     <td> Broadcast message at the beginning of your view template, can be used to alert users of scheduled downtimes; is set in [[Main/TWikiPreferences]]</td>
116   </tr>
117 </table>
118
119 <a name="GoBox"></a>
120
121 ### <a name="The &quot;Go&quot; Box and Navigation Box"></a> The "Go" Box and Navigation Box
122
123 The `%WEBTOPICLIST%` includes a "Go" box to jump to a topic. The box also understand URLs, e.g. you can type <http://www.google.com/> to jump to an external web site. The feature is handy if you build a skin that has a select box of frequently used links, like Intranet home, employee database, sales database and such. A little JavaScript gets into action on the onSelect method of the select tag to fill the selected URL into the "Go" box field, then submits the form.
124
125 Here is an example form that has a select box and the "Go" box for illustration purposes. You need to have JavaScript enabled for this to work:
126
127 <form action="http://www.dementia.org/twiki//view/%WEB%/%TOPIC%" name="sample">
128   <table border="3">
129     <tr>
130       <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">Navigate...</option>
131           <option value="http://www.twiki.org/">Intranet home</option>
132           <option value="Main.TWikiUsers">Employee index</option>
133           <option value="Main.WebHome">Main web</option>
134           <option value="TWiki.WebHome">TWiki web</option>
135           <option value="http://www.google.com/">Google</option>
136           <option value="http://www.yahoo.com/">Yahoo!</option></select> Bare bones header for demo only </td>
137     </tr>
138     <tr>
139       <td> %WEBTOPICLIST% </td>
140     </tr>
141   </table>
142 </form>
143
144 ## <a name="Using Cascading Style Sheets"></a> Using Cascading Style Sheets
145
146 The regular templates files currently do not use style sheets. Many skin developers choose to use them, it helps in separating style from content.
147
148 Example: To use a style sheet for the broadcast message, add this to `view.myskin.tmpl`:
149
150     <style type="text/css">
151     .broadcastmessage {
152         background: yellow; display:block;
153         border-style:solid;border-width: 2px;border-color:red;
154     }
155     .broadcastmessage strong {color: red}
156     </style>
157
158 Then add a div tag to the `%BROADCASTMESSAGE%` variable located after the `#PageTop` anchor or after the opening form tag:
159
160     <div class="broadcastmessage"> %BROADCASTMESSAGE% </div>
161
162 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
163
164 See TWiki:Plugins/SkinPackagingHowTo and TWiki:Plugins/SkinDeveloperFAQ
165
166 ## <a name="Activating Skins"></a> Activating Skins
167
168 A skin can be activated in two ways:
169
170 - Define the `SKIN` Preference variable in [[TWikiPreferences]], one of the [[WebPreferences]], or in a user - Main.admin - topic.
171   - `Set SKIN = print`
172
173 - Add `?skin=name` to the URL, for this example:
174   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=print> (for the print view skin)
175   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=plain> (for the plain view skin that has no header and footer)
176
177 The <code>**?skin=name**</code> URL parameter overrides the SKIN Preference value.
178
179 -- [[PeterThoeny]] - 05 Jan 2003