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="#Changing the default TWiki skin"> Changing the default TWiki skin</a></li>
6         <li><a href="#Defining Skins"> Defining Skins</a></li>
7         <li><a href="#Variables in Skins"> Variables in Skins</a><ul>
8             <li><a href="#The "Go" Box and Navigation Box"> The "Go" Box and Navigation Box</a></li>
9           </ul>
10         </li>
11         <li><a href="#Using Cascading Style Sheets"> Using Cascading Style Sheets</a></li>
12         <li><a href="#Attachment Tables"> Attachment Tables</a></li>
13         <li><a href="#Packaging and Publishing Skins"> Packaging and Publishing Skins</a></li>
14         <li><a href="#Browsing Installed Skins"> Browsing Installed Skins</a></li>
15         <li><a href="#Activating Skins"> Activating Skins</a></li>
16         <li><a href="#Hard-Coded Skins"> Hard-Coded Skins</a></li>
17       </ul>
18     </li>
19   </ul>
20 </div>
21
22 # <a name="TWiki Skins"></a> TWiki Skins
23
24 _Skins overlay regular templates to give different looks and feels to TWiki screens._
25
26 ## <a name="Overview"></a> Overview
27
28 TWiki uses [[TWikiTemplates]] files as the basis of all the screens it uses to interact with users. Each screen has an associated template file that contains the basic layout of the screen. This is then filled in by the code to generate what you see in the browser.
29
30 TWiki ships with a default set of template files that give a basic look-and-feel. TWiki also includes support for _skins_ that can be selected to give different, more sophisticated, look and feels. A default TWiki installation will usually start up with the [[PatternSkin]] already selected. Skins may also be defined by third parties and loaded into a TWiki installation to give more options. To see how TWiki looks when **no** skin is selected, [[view this topic with a non-existant skin|%WEB%/%TOPIC%?skin=not_a_skin]].
31
32 Topic text is not affected by the choice of skin, though a skin can be defined to use a CSS (Cascading Style Sheet), which can sometimes give a radically different appearance to the text.
33
34 **_%T% Tip:_** TWiki:TWiki.TWikiSkinsSupplement on TWiki.org has supplemental documentation on TWiki Skins.
35
36 ## <a name="Changing the default TWiki skin"></a> Changing the default TWiki skin
37
38 TWiki default ships with the skin [[PatternSkin]] activated. If you want to modify the layout, colors or even the templates to suit your own needs, have a look first at the topics [[PatternSkinCustomization]] and [[PatternSkinCssCookbook]].
39
40 ## <a name="Defining Skins"></a> Defining Skins
41
42 You may want to define your own skin, for example to comply with corporate web guidelines, or because you have a aesthetic vision that you want to share.
43
44 The [[TWikiTemplates]] files used for skins are located in the `twiki/templates` directory and are named according to the skin: <code>**&lt;scriptname&gt;.&lt;skin&gt;.tmpl**</code>. For example, the template used for pages generated by the `view` script with the `print` skin selected is `view.print.tmpl` (this is how the **Printable** control is implemented). Skin files may also be defined in TWiki topics - see [[TWikiTemplates]] for details.
45
46 To start creating a new skin, copy the default [[TWikiTemplates]] (like `view.tmpl`), or copy an existing skin to use as a base for your own skin. You should only need to copy the files you intend to customise, as TWiki can be configured to fall back to another skin if a template is not defined in your skin. Name the files as described above (for example `view.myskin.tmpl`.
47
48 **_%X% Note:_** Two skin names have _reserved_ meanings; `text` skin, and skin names starting with `rss` have [[hard-coded meanings|Main/WebHome#HardCodedSkins]].
49
50 The following template files are used for TWiki screens, and are referenced in the TWiki core code. If a skin doesn't define its own version of a template file, then TWiki will fall back to the next skin in the skin path, or finally, to the default version of the template file.
51
52 (Certain template files are expected to provide certain TMPL:DEFs - these are listed in sub-bullets)
53
54 - `addform` - used to select a new form for a topic
55 - `attachagain` - used when refreshing an existing attachment
56 - `attachnew` - used when attaching a new file to a topic
57 - `attachtables` - defines the format of attachments at the bottom of the standard topic view
58   - `ATTACH:files:footer`, `ATTACH:files:header`, `ATTACH:files:row`, `ATTACH:versions:footer`, `ATTACH:versions:header`, `ATTACH:versions:row`
59 - `changeform` - used to change the form in a topic
60 - `changes` - used by the `changes` script
61 - `edit` - used for the edit screen
62 - `form`
63 - `formtables` - used to defined the format of forms
64   - `FORM:display:footer`, `FORM:display:header`, `FORM:display:row`
65 - `login` - used for loggin in when using the TemplateLoginManager
66   - `LOG_IN`, `LOG_IN_BANNER`, `LOG_OUT`, `LOGGED_IN_BANNER`, `NEW_USER_NOTE`, `UNRECOGNISED_USER`
67 - `moveattachment` - used when moving an attachment
68 - `oopsaccessdenied` - used to format Access Denied messages
69   - `no_such_topic`, `no_such_web`, `only_group`, `topic_access`
70 - `oopsattention` - used to format Attention messages
71   - `already_exists`, `bad_email`, `bad_ver_code`, `bad_wikiname`, `base_web_missing`, `confirm`, `created_web`, `delete_err`, `invalid_web_color`, `invalid_web_name`, `in_a_group`, `mandatory_field`, `merge_notice`, `missing_action`, `missing_fields`, `move_err`, `missing_action`, `no_form_def`, `no_users_to_reset`, `notwikiuser`, `oversized_upload`, `password_changed`, `password_mismatch`, `problem_adding`, `remove_user_done`, `rename_err`, `rename_not_wikiword`, `rename_topic_exists`, `rename_web_err`, `rename_web_exists`, `rename_web_prerequisites`, `reset_bad`, `reset_ok`, `save_error`, `send_mail_error`, `thanks`, `topic_exists`, `unrecognized_action`, `upload_name_changed`, `web_creation_error`, `web_exists`, `web_missing`, `wrong_password`, `zero_size_upload`
72 - `oopschangelanguage` - used to prompt for a new language when internationalisation is enabled
73 - `oopslanguagechanged` - used to confirm a new language when internationalisation is enabled
74 - `oopsleaseconflict` - used to format lease Conflict messages
75   - `lease_active`, `lease_old`
76 - `preview` - used for previewing edited topics before saving
77 - `rdiff` - used for viewing topic differences
78 - `registernotify` - used by the user registration system
79 - `registernotifyadmin` - used by the user registration system
80 - `rename` - used when renaming a topic
81 - `renameconfirm` - used when renaming a topic
82 - `renamedelete` - used when renaming a topic
83 - `renameweb` - used when renaming a web
84 - `renamewebconfirm` - used when renaming a web
85 - `renamewebdelete` - used when renaming a web
86 - `searchbookview` - used to format inline search results in book view
87 - `searchformat` - used to format inline search results
88 - `search` - used by the `search` CGI script
89 - `settings`
90 - `view` - used by the `view` CGI script
91
92 `twiki.tmpl` is a master template conventionally used by other templates, but not used directly by code.
93
94 **_%X% Note:_** You are strongly recommended **not** to `TMPL:INCLUDE` the default templates, or templates from other skins, when you are defining your own skin. If you do, you run the risk that the included file might change and break your skin.
95
96 ## <a name="Variables in Skins"></a> Variables in Skins
97
98 You can use [[template variables|Main/TWikiTemplates#TemplateVariables]], [[TWikiVariables]], and other predefined variables to compose your skins. Some commonly used variables in skins:
99
100 <table border="1" cellpadding="0" cellspacing="0">
101   <tr>
102     <th bgcolor="#99CCCC"><strong> Variable: </strong></th>
103     <th bgcolor="#99CCCC"><strong> Expanded to: </strong></th>
104   </tr>
105   <tr>
106     <td><code>%WEBLOGONAME%</code></td>
107     <td> Filename of web logo </td>
108   </tr>
109   <tr>
110     <td><code>%WEBLOGOIMG%</code></td>
111     <td> Image URL of web logo </td>
112   </tr>
113   <tr>
114     <td><code>%WEBLOGOURL%</code></td>
115     <td> Link of web logo </td>
116   </tr>
117   <tr>
118     <td><code>%WEBLOGOALT%</code></td>
119     <td> Alt text of web logo </td>
120   </tr>
121   <tr>
122     <td><code>%WIKILOGOURL%</code></td>
123     <td> Link of page logo </td>
124   </tr>
125   <tr>
126     <td><code>%WIKILOGOIMG%</code></td>
127     <td> Image URL of page logo </td>
128   </tr>
129   <tr>
130     <td><code>%WIKILOGOALT%</code></td>
131     <td> Alt text of page logo </td>
132   </tr>
133   <tr>
134     <td><code>%WEBBGCOLOR%</code></td>
135     <td> Web-specific background color, defined in the [[Main/WebPreferences]]</td>
136   </tr>
137   <tr>
138     <td><code>%WIKITOOLNAME%</code></td>
139     <td> The name of your TWiki site </td>
140   </tr>
141   <tr>
142     <td><code>%SCRIPTURL%</code></td>
143     <td> The script URL of TWiki </td>
144   </tr>
145   <tr>
146     <td><code>%SCRIPTURLPATH%</code></td>
147     <td> The script URL path </td>
148   </tr>
149   <tr>
150     <td><code>%SCRIPTSUFFIX%</code></td>
151     <td> The script suffix, ex: <code>.pl</code>, <code>.cgi</code></td>
152   </tr>
153   <tr>
154     <td><code>%WEB%</code></td>
155     <td> The name of the current web. </td>
156   </tr>
157   <tr>
158     <td><code>%TOPIC%</code></td>
159     <td> The name of the current topic. </td>
160   </tr>
161   <tr>
162     <td><code>%WEBTOPICLIST%</code></td>
163     <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
164   </tr>
165   <tr>
166     <td><code>%TEXT%</code></td>
167     <td> The topic text, e.g. the content that can be edited </td>
168   </tr>
169   <tr>
170     <td><code>%META{"form"}%</code></td>
171     <td>[[Main/TWikiForms]], if any </td>
172   </tr>
173   <tr>
174     <td><code>%META{"attachments"}%</code></td>
175     <td>[[Main/FileAttachment]] table </td>
176   </tr>
177   <tr>
178     <td><code>%META{"parent"}%</code></td>
179     <td> The topic parent </td>
180   </tr>
181   <tr>
182     <td><code>%EDITTOPIC%</code></td>
183     <td> Edit link </td>
184   </tr>
185   <tr>
186     <td><code>%REVTITLE%</code></td>
187     <td> The revision title, if any, ex: <code>(r1.6)</code></td>
188   </tr>
189   <tr>
190     <td><code>%REVINFO%</code></td>
191     <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
192   </tr>
193   <tr>
194     <td><code>%WEBCOPYRIGHT%</code></td>
195     <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
196   </tr>
197   <tr>
198     <td><code>%BROADCASTMESSAGE%</code></td>
199     <td> Broadcast message at the beginning of your view template, can be used to alert users of scheduled downtimes; can be set in [[Main/TWikiPreferences]]</td>
200   </tr>
201 </table>
202
203 <a name="GoBox"></a>
204
205 ### <a name="The &quot;Go&quot; Box and Navigation Box"></a> The "Go" Box and Navigation Box
206
207 The default `%WEBTOPICLIST%` includes a "Go" box, also called "Jump" box, to jump to a topic. The box also understands 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.
208
209 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:
210
211 <form action="http://www.dementia.org/twiki/view/%WEB%/%TOPIC%" name="sample">
212   <table border="3">
213     <tr>
214       <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">Navigate...</option>
215           <option value="http://www.twiki.org/">Intranet home</option>
216           <option value="Main.TWikiUsers">Employee index</option>
217           <option value="Main.WebHome">Main web</option>
218           <option value="TWiki.WebHome">TWiki web</option>
219           <option value="http://www.google.com/">Google</option>
220           <option value="http://www.yahoo.com/">Yahoo!</option></select> Bare bones header for demo only </td>
221     </tr>
222     <tr>
223       <td> %WEBTOPICLIST% </td>
224     </tr>
225   </table>
226 </form>
227
228 ## <a name="Using Cascading Style Sheets"></a> Using Cascading Style Sheets
229
230 CSS is used by [[PatternSkin]], the TWiki skin that is selected in new installations. See that skin topic for information how CSS is used.
231
232 CSS files are gererally attachments to the skin topic that are included in the the skin templates - in the case of [[PatternSkin]] in the template `css.pattern.tmpl`.
233
234 Write in your main template:
235
236     <style type='text/css' media='all'>@import url('%PUBURLPATH%/%TWIKIWEB%/MySkin/mystyle.css');</style>
237
238 ## <a name="Attachment Tables"></a> Attachment Tables
239
240 Controlling the look and feel of attachment tables is a little bit more complex than for the rest of a skin. By default, the attachment table is a standard TWiki table, and the look is controlled in the same way as other tables. In a very few cases you may want to change the _content_ of the table as well.
241
242 The format of standard attachment tables is defined through the use of special _TWiki template macros_ which by default, are defined in the `attachtables.tmpl` template using the `%TMPL:DEF` macro syntax described in [[TWikiTemplates]]. These macros are:
243
244 <table border="1" cellpadding="0" cellspacing="0">
245   <tr>
246     <th bgcolor="#99CCCC"><strong> Macro </strong></th>
247     <th bgcolor="#99CCCC"><strong> Description </strong></th>
248   </tr>
249   <tr>
250     <td><code>ATTACH:files:header</code></td>
251     <td> Standard title bar </td>
252   </tr>
253   <tr>
254     <td><code>ATTACH:files:row</code></td>
255     <td> Standard row </td>
256   </tr>
257   <tr>
258     <td><code>ATTACH:files:footer</code></td>
259     <td> Footer for all screens </td>
260   </tr>
261   <tr>
262     <td><code>ATTACH:files:header:A</code></td>
263     <td> Title bar for upload screens, with attributes column </td>
264   </tr>
265   <tr>
266     <td><code>ATTACH:files:row:A</code></td>
267     <td> Row for upload screen </td>
268   </tr>
269   <tr>
270     <td><code>ATTACH:files:footer:A</code></td>
271     <td> Footer for all screens </td>
272   </tr>
273 </table>
274
275 The format of tables of file versions in the Upload screen can also be changed, using the macros:
276
277 <table border="1" cellpadding="0" cellspacing="0">
278   <tr>
279     <th bgcolor="#99CCCC"><strong> Macro </strong></th>
280     <th bgcolor="#99CCCC"><strong> Description </strong></th>
281   </tr>
282   <tr>
283     <td><code>ATTACH:versions:header</code></td>
284     <td> Header for versions table on upload screen </td>
285   </tr>
286   <tr>
287     <td><code>ATTACH:versions:row</code></td>
288     <td> Row format for versions table on upload screen </td>
289   </tr>
290   <tr>
291     <td><code>ATTACH:versions:footer</code></td>
292     <td> Footer for versions table on upload screen </td>
293   </tr>
294 </table>
295
296 The `ATTACH:row` macros are expanded for each file in the attachment table, using the following special tags:
297
298 <table border="1" cellpadding="0" cellspacing="0">
299   <tr>
300     <th bgcolor="#99CCCC"><strong> Tag </strong></th>
301     <th bgcolor="#99CCCC"><strong> Description </strong></th>
302   </tr>
303   <tr>
304     <td><code>%A_URL%</code></td>
305     <td> URL that will recover the file </td>
306   </tr>
307   <tr>
308     <td><code>%A_REV%</code></td>
309     <td> Revision of this file </td>
310   </tr>
311   <tr>
312     <td><code>%A_ICON%</code></td>
313     <td> A file icon suitable for representing the attachment content </td>
314   </tr>
315   <tr>
316     <td><code>%A_FILE%</code></td>
317     <td> The name of the file </td>
318   </tr>
319   <tr>
320     <td><code>%A_SIZE%</code></td>
321     <td> The size of the file </td>
322   </tr>
323   <tr>
324     <td><code>%A_DATE%</code></td>
325     <td> The date the file was uploaded </td>
326   </tr>
327   <tr>
328     <td><code>%A_USER%</code></td>
329     <td> The user who uploaded it </td>
330   </tr>
331   <tr>
332     <td><code>%A_COMMENT%</code></td>
333     <td> The comment they put in when uploading it </td>
334   </tr>
335   <tr>
336     <td><code>%A_ATTRS%</code></td>
337     <td> The attributes of the file as seen on the upload screen e.g "h" for a hidden file </td>
338   </tr>
339 </table>
340
341 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
342
343 See TWiki:Plugins/SkinPackagingHowTo and TWiki:Plugins/SkinDeveloperFAQ
344
345 ## <a name="Browsing Installed Skins"></a> Browsing Installed Skins
346
347 You can try out all installed skins in the [[TWikiSkinBrowser]].
348
349 ## <a name="Activating Skins"></a> Activating Skins
350
351 TWiki uses a _skin search path_, which lets you combine skins additively. The skin path is defined using a combination of [[TWikiVariables]] and URL parameters.
352
353 TWiki works by asking for a template for a particular function - for example, 'view'. The detail of how templates are searched for is described in [[TWikiTemplates]], but in summary, the templates directory is searched for a file called `view.`_skin_`.tmpl`, where _skin_ is the name of the skin e.g. `pattern`. If no template is found, then the fallback is to use `view.tmpl`. Each skin on the path is searched for in turn. For example, if you have set the skin path to `local,pattern` then `view.local.tmpl` will be searched for first, then `view.pattern.tmpl` and finally `view.tmpl`.
354
355 The basic skin is defined by a `SKIN` setting:
356
357 - `Set SKIN = catskin, bearskin`
358
359 You can also add a parameter to the URL, such as `?skin=catskin, bearskin`. Example activation of [[PrintSkin]] that generates a printable page:
360
361 - [[http://www.dementia.org/twiki/view/%WEB%/%TOPIC%?skin=print|%WEB%/%TOPIC%?skin=print]]
362
363 Setting `SKIN` (or the `?skin` parameter in the URL) replaces the existing skin path setting. You can also _extend_ the existing skin path as well, using _covers_.
364
365 - `Set COVER = ruskin`
366
367 This pushes a different skin to the front of the skin search path (so for our example above, that final skin path will be `ruskin, catskin, bearskin`). There is also an equivalent `cover` URL parameter.
368
369 The full skin path is built up as follows: `SKIN` setting (or `?skin` if it is set), then `COVER` setting is added, then `?cover`.
370
371 <a name="HardCodedSkins"></a>
372
373 ## <a name="Hard-Coded Skins"></a> Hard-Coded Skins
374
375 The `text` skin is reserved for TWiki internal use.
376
377 Skin names starting with `rss` also have a special meaning; if one or more of the skins in the skin path starts with 'rss' then 8-bit characters will be encoded as XML entities in the output, and the `content-type` header will be forced to `text/xml`.
378
379 **_Related Topics:_** [[TWikiSkinBrowser]], [[AdminDocumentationCategory]], [[DeveloperDocumentationCategory]], TWiki:TWiki.TWikiSkinsSupplement
380
381 -- **_Contributors:_** TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.CrawfordCurrie