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><ul>
7             <li><a href="#Partial customisation, or adding"> Partial customisation, or adding in new features to an existing skin</a></li>
8           </ul>
9         </li>
10         <li><a href="#Variables in Skins"> Variables in Skins</a></li>
11         <li><a href="#The "Go" Box and Navigation Box"> The "Go" Box and Navigation Box</a></li>
12         <li><a href="#Using Cascading Style Sheets"> Using Cascading Style Sheets</a></li>
13         <li><a href="#Attachment Tables"> Attachment Tables</a></li>
14         <li><a href="#Packaging and Publishing Skins"> Packaging and Publishing Skins</a></li>
15         <li><a href="#Browsing Installed Skins"> Browsing Installed Skins</a></li>
16         <li><a href="#Activating Skins"> Activating Skins</a></li>
17         <li><a href="#Hard-Coded Skins"> Hard-Coded Skins</a></li>
18       </ul>
19     </li>
20   </ul>
21 </div>
22
23 # <a name="TWiki Skins"></a> TWiki Skins
24
25 _Skins overlay regular templates to give different looks and feels to TWiki screens._
26
27 ## <a name="Overview"></a> Overview
28
29 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.
30
31 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]].
32
33 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.
34
35 **_Relevant links on TWiki.org:_**
36
37 - TWiki:TWiki.TWikiSkinsSupplement - **_%T% tip:_** supplemental documentation on TWiki skins
38 - TWiki:Plugins.SkinPackage - list of all contributed skin packages
39 - TWiki:Plugins.SkinDevelopment - discussion and feedback on contributed skins
40 - TWiki:Plugins.SkinBrainstorming - open forum for new skin ideas
41 - TWiki:Plugins.SkinPackageHowTo - template to create a new skin package
42
43 **_See other types of extensions:_** [[TWikiAddOns]], [[TWikiContribs]], [[TWikiPlugins]]
44
45 ## <a name="Changing the default TWiki skin"></a> Changing the default TWiki skin
46
47 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]].
48
49 ## <a name="Defining Skins"></a> Defining Skins
50
51 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.
52
53 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>. Skin files may also be defined in TWiki topics - see [[TWikiTemplates]] for details.
54
55 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`.
56
57 For your own TWiki skin you are encouraged to show a small 80x31 pixel [<img src="http://www.dementia.org/twiki//view/TWiki/TWikiLogos/T-logo-80x15.gif" width="80" height="15" alt="This site is powered by the TWiki collaboration platform" title="This site is powered by the TWiki collaboration platform" />](http://twiki.org/) logo at the bottom of your skin:
58
59 `<a href="http://twiki.org/"><img src="%PUBURL%/%TWIKIWEB%/TWikiLogos/T-logo-80x15.gif" alt="This site is powered by the TWiki collaboration platform" width="80" height="15" title="This site is powered by the TWiki collaboration platform" border="0" /></a>`
60
61 The standard TWiki skins show the logo in the `%WEBCOPYRIGHT%` variable.
62
63 **_%X% Note:_** Two skin names have _reserved_ meanings; `text` skin, and skin names starting with `rss` have [[hard-coded meanings|Main/WebHome#HardCodedSkins]].
64
65 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.
66
67 (Certain template files are expected to provide certain TMPL:DEFs - these are listed in sub-bullets)
68
69 - `addform` - used to select a new form for a topic
70 - `attachagain` - used when refreshing an existing attachment
71 - `attachnew` - used when attaching a new file to a topic
72 - `attachtables` - defines the format of attachments at the bottom of the standard topic view
73   - `ATTACH:files:footer`, `ATTACH:files:header`, `ATTACH:files:row`, `ATTACH:versions:footer`, `ATTACH:versions:header`, `ATTACH:versions:row`
74 - `changeform` - used to change the form in a topic
75 - `changes` - used by the `changes` script
76 - `edit` - used for the edit screen
77 - `form`
78 - `formtables` - used to defined the format of forms
79   - `FORM:display:footer`, `FORM:display:header`, `FORM:display:row`
80 - `login` - used for loggin in when using the TemplateLoginManager
81   - `LOG_IN`, `LOG_IN_BANNER`, `LOG_OUT`, `LOGGED_IN_BANNER`, `NEW_USER_NOTE`, `UNRECOGNISED_USER`
82 - `moveattachment` - used when moving an attachment
83 - `oopsaccessdenied` - used to format Access Denied messages
84   - `no_such_topic`, `no_such_web`, `only_group`, `topic_access`
85 - `oopsattention` - used to format Attention messages
86   - `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`
87 - `oopschangelanguage` - used to prompt for a new language when internationalisation is enabled
88 - `oopsgeneric` - a basic dialog for user information; provides "ok" button only
89 - `oopslanguagechanged` - used to confirm a new language when internationalisation is enabled
90 - `oopsleaseconflict` - used to format lease Conflict messages
91   - `lease_active`, `lease_old`
92 - `preview` - used for previewing edited topics before saving
93 - `rdiff` - used for viewing topic differences
94 - `registernotify` - used by the user registration system
95 - `registernotifyadmin` - used by the user registration system
96 - `rename` - used when renaming a topic
97 - `renameconfirm` - used when renaming a topic
98 - `renamedelete` - used when renaming a topic
99 - `renameweb` - used when renaming a web
100 - `renamewebconfirm` - used when renaming a web
101 - `renamewebdelete` - used when renaming a web
102 - `searchbookview` - used to format inline search results in book view
103 - `searchformat` - used to format inline search results
104 - `search` - used by the `search` CGI script
105 - `settings`
106 - `view` - used by the `view` CGI script
107 - `viewprint` - used to create the printable view
108
109 `twiki.tmpl` is a master template conventionally used by other templates, but not used directly by code.
110
111 **_%X% Note:_** It is best to create these templates for your skin. If you `TMPL:INCLUDE` the default templates, or templates from other skins, when you are defining your own skin, you run the risk that the included file might change and break your skin.
112
113 ### <a name="Partial customisation, or adding"></a> Partial customisation, or adding in new features to an existing skin
114
115 You can use recusion in the TMPL:INCLUDE chain (eg twiki.classic.tmpl contains `%TMPL:INCLUDE{"twiki"}%`, the templating system will include the next twiki.SKIN in the skin path. For example, to create a customisation of pattern skin, where you _only_ want to remove the edit &amp; WYSIWYG buttons from view page, you create only a `view.yourlocal.tmpl`:
116
117     %TMPL:INCLUDE{"view"}%
118     %TMPL:DEF{"edit_topic_link"}%%TMPL:END%
119     %TMPL:DEF{"edit_wysiwyg_link"}%%TMPL:END%
120
121 and then set `SKIN=yourlocal,pattern`.
122
123 Because [[ClassicSkin]] and the default templates use the same Template definition names, you can over-ride the edit links in them (or any skin derived from them) using the same `view.yourlocal.tmpl` (just set SKIN=yourlocal,classic either in [[TWikiPreferences]] for globally, or a Web's Webname.WebPreferences for a particular web)
124
125 ## <a name="Variables in Skins"></a> Variables in Skins
126
127 You can use [[template variables|Main/TWikiTemplates#TemplateVariables]], [[TWikiVariables]], and other predefined variables to compose your skins. Some commonly used variables in skins:
128
129 <table border="1" cellpadding="0" cellspacing="0">
130   <tr>
131     <th bgcolor="#99CCCC"><strong> Variable: </strong></th>
132     <th bgcolor="#99CCCC"><strong> Expanded to: </strong></th>
133   </tr>
134   <tr>
135     <td><code>%WEBLOGONAME%</code></td>
136     <td> Filename of web logo </td>
137   </tr>
138   <tr>
139     <td><code>%WEBLOGOIMG%</code></td>
140     <td> Image URL of web logo </td>
141   </tr>
142   <tr>
143     <td><code>%WEBLOGOURL%</code></td>
144     <td> Link of web logo </td>
145   </tr>
146   <tr>
147     <td><code>%WEBLOGOALT%</code></td>
148     <td> Alt text of web logo </td>
149   </tr>
150   <tr>
151     <td><code>%WIKILOGOURL%</code></td>
152     <td> Link of page logo </td>
153   </tr>
154   <tr>
155     <td><code>%WIKILOGOIMG%</code></td>
156     <td> Image URL of page logo </td>
157   </tr>
158   <tr>
159     <td><code>%WIKILOGOALT%</code></td>
160     <td> Alt text of page logo </td>
161   </tr>
162   <tr>
163     <td><code>%WEBBGCOLOR%</code></td>
164     <td> Web-specific background color, defined in the [[Main/WebPreferences]]</td>
165   </tr>
166   <tr>
167     <td><code>%WIKITOOLNAME%</code></td>
168     <td> The name of your TWiki site </td>
169   </tr>
170   <tr>
171     <td><code>%SCRIPTURL%</code></td>
172     <td> The script URL of TWiki </td>
173   </tr>
174   <tr>
175     <td><code>%SCRIPTURLPATH%</code></td>
176     <td> The script URL path </td>
177   </tr>
178   <tr>
179     <td><code>%SCRIPTSUFFIX%</code></td>
180     <td> The script suffix, ex: <code>.pl</code>, <code>.cgi</code></td>
181   </tr>
182   <tr>
183     <td><code>%WEB%</code></td>
184     <td> The name of the current web. </td>
185   </tr>
186   <tr>
187     <td><code>%TOPIC%</code></td>
188     <td> The name of the current topic. </td>
189   </tr>
190   <tr>
191     <td><code>%WEBTOPICLIST%</code></td>
192     <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
193   </tr>
194   <tr>
195     <td><code>%TEXT%</code></td>
196     <td> The topic text, e.g. the content that can be edited </td>
197   </tr>
198   <tr>
199     <td><code>%META{"form"}%</code></td>
200     <td>[[Main/TWikiForms]], if any </td>
201   </tr>
202   <tr>
203     <td><code>%META{"attachments"}%</code></td>
204     <td>[[Main/FileAttachment]] table </td>
205   </tr>
206   <tr>
207     <td><code>%META{"parent"}%</code></td>
208     <td> The topic parent </td>
209   </tr>
210   <tr>
211     <td><code>%EDITTOPIC%</code></td>
212     <td> Edit link </td>
213   </tr>
214   <tr>
215     <td><code>%REVTITLE%</code></td>
216     <td> The revision title, if any, ex: <code>(r1.6)</code></td>
217   </tr>
218   <tr>
219     <td><code>%REVINFO%</code></td>
220     <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
221   </tr>
222   <tr>
223     <td><code>%WEBCOPYRIGHT%</code></td>
224     <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
225   </tr>
226   <tr>
227     <td><code>%BROADCASTMESSAGE%</code></td>
228     <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>
229   </tr>
230 </table>
231
232 <a name="GoBox"></a>
233
234 ## <a name="The &quot;Go&quot; Box and Navigation Box"></a> The "Go" Box and Navigation Box
235
236 The default skins include a [["Go" box|Main/GoBox]], also called "Jump" box, to jump to a topic.
237
238 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 `onchange` method of the select tag to fill the selected URL into the "Go" box field, then submits the form.
239
240 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:
241
242 <form action="http://www.dementia.org/twiki/view/%WEB%/%TOPIC%" name="sample">
243   <table bgcolor="#DDDDDD" border="0" cellpadding="5">
244     <tr>
245       <td colspan="2"> Bare bones header, for demo only </td>
246     </tr>
247     <tr>
248       <td> Navigate: </td>
249       <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">...</option>
250           <option value="http://twiki.org/">Intranet home</option>
251           <option value="Main.TWikiUsers">Employee index</option>
252           <option value="Main.WebHome">Main web</option>
253           <option value="TWiki.WebHome">TWiki web</option>
254           <option value="http://www.google.com/">Google</option>
255           <option value="http://www.yahoo.com/">Yahoo!</option></select></td>
256     </tr>
257     <tr>
258       <td> Jump: </td>
259       <td><input name="topic" size="16" type="text" /></td>
260     </tr>
261   </table>
262 </form>
263
264 **_Note:_** Redirect to a URL only works if it is enabled in `configure` (Miscellaneous, `{AllowRedirectUrl}`).
265
266 ## <a name="Using Cascading Style Sheets"></a> Using Cascading Style Sheets
267
268 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 `styles.pattern.tmpl`.
269
270 - To see how CSS is used in the default TWiki skin, see: [[PatternSkin]]
271 - If you write a complete new skin, this is the syntax to use in a template file:
272
273     <style type='text/css' media='all'>@import url('%PUBURLPATH%/%TWIKIWEB%/MySkin/mystyle.css');</style>
274
275 ## <a name="Attachment Tables"></a> Attachment Tables
276
277 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.
278
279 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:
280
281 <table border="1" cellpadding="0" cellspacing="0">
282   <tr>
283     <th bgcolor="#99CCCC"><strong> Macro </strong></th>
284     <th bgcolor="#99CCCC"><strong> Description </strong></th>
285   </tr>
286   <tr>
287     <td><code>ATTACH:files:header</code></td>
288     <td> Standard title bar </td>
289   </tr>
290   <tr>
291     <td><code>ATTACH:files:row</code></td>
292     <td> Standard row </td>
293   </tr>
294   <tr>
295     <td><code>ATTACH:files:footer</code></td>
296     <td> Footer for all screens </td>
297   </tr>
298   <tr>
299     <td><code>ATTACH:files:header:A</code></td>
300     <td> Title bar for upload screens, with attributes column </td>
301   </tr>
302   <tr>
303     <td><code>ATTACH:files:row:A</code></td>
304     <td> Row for upload screen </td>
305   </tr>
306   <tr>
307     <td><code>ATTACH:files:footer:A</code></td>
308     <td> Footer for all screens </td>
309   </tr>
310 </table>
311
312 The format of tables of file versions in the Upload screen can also be changed, using the macros:
313
314 <table border="1" cellpadding="0" cellspacing="0">
315   <tr>
316     <th bgcolor="#99CCCC"><strong> Macro </strong></th>
317     <th bgcolor="#99CCCC"><strong> Description </strong></th>
318   </tr>
319   <tr>
320     <td><code>ATTACH:versions:header</code></td>
321     <td> Header for versions table on upload screen </td>
322   </tr>
323   <tr>
324     <td><code>ATTACH:versions:row</code></td>
325     <td> Row format for versions table on upload screen </td>
326   </tr>
327   <tr>
328     <td><code>ATTACH:versions:footer</code></td>
329     <td> Footer for versions table on upload screen </td>
330   </tr>
331 </table>
332
333 The `ATTACH:row` macros are expanded for each file in the attachment table, using the following special tags:
334
335 <table border="1" cellpadding="0" cellspacing="0">
336   <tr>
337     <th bgcolor="#99CCCC"><strong> Tag </strong></th>
338     <th bgcolor="#99CCCC"><strong> Description </strong></th>
339   </tr>
340   <tr>
341     <td><code>%A_URL%</code></td>
342     <td> URL that will recover the file </td>
343   </tr>
344   <tr>
345     <td><code>%A_REV%</code></td>
346     <td> Revision of this file </td>
347   </tr>
348   <tr>
349     <td><code>%A_ICON%</code></td>
350     <td> A file icon suitable for representing the attachment content </td>
351   </tr>
352   <tr>
353     <td><code>%A_FILE%</code></td>
354     <td> The name of the file </td>
355   </tr>
356   <tr>
357     <td><code>%A_SIZE%</code></td>
358     <td> The size of the file </td>
359   </tr>
360   <tr>
361     <td><code>%A_DATE%</code></td>
362     <td> The date the file was uploaded </td>
363   </tr>
364   <tr>
365     <td><code>%A_USER%</code></td>
366     <td> The user who uploaded it </td>
367   </tr>
368   <tr>
369     <td><code>%A_COMMENT%</code></td>
370     <td> The comment they put in when uploading it </td>
371   </tr>
372   <tr>
373     <td><code>%A_ATTRS%</code></td>
374     <td> The attributes of the file as seen on the upload screen e.g "h" for a hidden file </td>
375   </tr>
376 </table>
377
378 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
379
380 See TWiki:Plugins/SkinPackagingHowTo and TWiki:Plugins/SkinDeveloperFAQ
381
382 ## <a name="Browsing Installed Skins"></a> Browsing Installed Skins
383
384 You can try out all installed skins in the [[TWikiSkinBrowser]].
385
386 ## <a name="Activating Skins"></a> Activating Skins
387
388 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.
389
390 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`.
391
392 The basic skin is defined by a `SKIN` setting:
393
394 - `Set SKIN = catskin, bearskin`
395
396 You can also add a parameter to the URL, such as `?skin=catskin,bearskin`:
397
398 - [[http://www.dementia.org/twiki/view/%WEB%/%TOPIC%?skin=catskin,bearskin|%WEB%/%TOPIC%?skin=catskin,bearskin]]
399
400 Setting `SKIN` (or the `?skin` parameter in the URL) replaces the existing skin path setting, for the current page only. You can also _extend_ the existing skin path as well, using _covers_.
401
402 - `Set COVER = ruskin`
403
404 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. The difference between setting `SKIN` vs. `COVER` is that if the chosen template is not found (e.g., for included templates), `SKIN` will fall back onto the next skin in line, or the default skin, if only one skin was present, while `COVER` will always fall back onto the current skin.
405
406 An example would be invoking the printable mode, which is achieved by applying `?cover=print`. The `view.print.tmpl` simply invokes the `viewprint` template for the current skin which then can appropriately include all other used templates for the current skin. Where the printable mode be applied by using `SKIN`, all skins would have the same printable appearance.
407
408 The full skin path is built up as follows: `SKIN` setting (or `?skin` if it is set), then `COVER` setting is added, then `?cover`.
409
410 <a name="HardCodedSkins"></a>
411
412 ## <a name="Hard-Coded Skins"></a> Hard-Coded Skins
413
414 The `text` skin is reserved for TWiki internal use.
415
416 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`.
417
418 **_Related Topics:_** [[TWikiSkinBrowser]], [[AdminDocumentationCategory]], [[DeveloperDocumentationCategory]], TWiki:TWiki.TWikiSkinsSupplement
419
420 -- **_Contributors:_** TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.CrawfordCurrie