1 # <a name="TWiki Skins"></a> TWiki Skins
3 _Skins overlay regular templates to give different looks and feels to TWiki screens._
7 <li><a href="#TWiki Skins"> TWiki Skins</a><ul>
8 <li><a href="#Overview"> Overview</a></li>
9 <li><a href="#Changing the default TWiki skin"> Changing the default TWiki skin</a></li>
10 <li><a href="#Defining Skins"> Defining Skins</a><ul>
11 <li><a href="#Partial customisation, or adding"> Partial customisation, or adding in new features to an existing skin</a></li>
14 <li><a href="#Variables in Skins"> Variables in Skins</a></li>
15 <li><a href="#The "Go" Box and Navigation Box"> The "Go" Box and Navigation Box</a></li>
16 <li><a href="#Using Cascading Style Sheets"> Using Cascading Style Sheets</a></li>
17 <li><a href="#Attachment Tables"> Attachment Tables</a></li>
18 <li><a href="#Packaging and Publishing Skins"> Packaging and Publishing Skins</a></li>
19 <li><a href="#Browsing Installed Skins"> Browsing Installed Skins</a></li>
20 <li><a href="#Activating Skins"> Activating Skins</a></li>
21 <li><a href="#Hard-Coded Skins"> Hard-Coded Skins</a></li>
27 ## <a name="Overview"></a> Overview
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.
31 TWiki ships with a default set of template files that give a very basic, CSS-themable, 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]].
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.
35 **_Relevant links on TWiki.org:_**
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
43 **_See other types of extensions:_** [[TWikiAddOns]], [[TWikiContribs]], [[TWikiPlugins]]
45 ## <a name="Changing the default TWiki skin"></a> Changing the default TWiki skin
47 TWiki default ships with the skin [[PatternSkin]] activated. You can set the skin for the whole site, a single web or topic, or for each user individually, by setting the SKIN variable to the name of a skin. If the skin you select doesn't exist, then TWiki will pick up the default templates.
49 ## <a name="Defining Skins"></a> Defining Skins
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. There are a couple of places you an start doing this.
53 The [[TWikiTemplates]] files used for skins are located in the `twiki/templates` directory and are named according to the skin: <code>**<scriptname>.<skin>.tmpl**</code>. Skin files may also be defined in TWiki topics - see [[TWikiTemplates]] for details.
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`.
57 If you use [[PatternSkin]] as your starting point, and 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]].
59 For your own TWiki skin you are encouraged to show a small 80x31 pixel [<img src="http://www.dementia.org/twiki//view/%SYSTEMWEB%/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:
61 `<a href="http://twiki.org/"><img src="%PUBURL%/%SYSTEMWEB%/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>`
63 The standard TWiki skins show the logo in the `%WEBCOPYRIGHT%` variable.
65 **_%X% Note:_** Two skin names have _reserved_ meanings; `text` skin, and skin names starting with `rss` have [[hard-coded meanings|Main/WebHome#HardCodedSkins]].
67 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.
69 (Certain template files are expected to provide certain TMPL:DEFs - these are listed in sub-bullets)
71 - `addform` - used to select a new form for a topic
72 - `attachagain` - used when refreshing an existing attachment
73 - `attachnew` - used when attaching a new file to a topic
74 - `attachtables` - defines the format of attachments at the bottom of the standard topic view
75 - `ATTACH:files:footer`, `ATTACH:files:header`, `ATTACH:files:row`, `ATTACH:versions:footer`, `ATTACH:versions:header`, `ATTACH:versions:row`
76 - `changeform` - used to change the form in a topic
77 - `changes` - used by the `changes` script
78 - `edit` - used for the edit screen
80 - `formtables` - used to defined the format of forms
81 - `FORM:display:footer`, `FORM:display:header`, `FORM:display:row`
82 - `login` - used for loggin in when using the TemplateLoginManager
83 - `LOG_IN`, `LOG_IN_BANNER`, `LOG_OUT`, `LOGGED_IN_BANNER`, `NEW_USER_NOTE`, `UNRECOGNISED_USER`
84 - `moveattachment` - used when moving an attachment
85 - `oopsaccessdenied` - used to format Access Denied messages
86 - `no_such_topic`, `no_such_web`, `only_group`, `topic_access`
87 - `oopsattention` - used to format Attention messages
88 - `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`
89 - `oopschangelanguage` - used to prompt for a new language when internationalisation is enabled
90 - `oopsgeneric` - a basic dialog for user information; provides "ok" button only
91 - `oopslanguagechanged` - used to confirm a new language when internationalisation is enabled
92 - `oopsleaseconflict` - used to format lease Conflict messages
93 - `lease_active`, `lease_old`
94 - `preview` - used for previewing edited topics before saving
95 - `rdiff` - used for viewing topic differences
96 - `registernotify` - used by the user registration system
97 - `registernotifyadmin` - used by the user registration system
98 - `rename` - used when renaming a topic
99 - `renameconfirm` - used when renaming a topic
100 - `renamedelete` - used when renaming a topic
101 - `renameweb` - used when renaming a web
102 - `renamewebconfirm` - used when renaming a web
103 - `renamewebdelete` - used when renaming a web
104 - `searchbookview` - used to format inline search results in book view
105 - `searchformat` - used to format inline search results
106 - `search` - used by the `search` CGI script
108 - `view` - used by the `view` CGI script
109 - `viewprint` - used to create the printable view
111 `twiki.tmpl` is a master template conventionally used by other templates, but not used directly by code.
113 **_%X% Note:_** Make sure templates do not end with a newline. Any newline will expand to an empty `<p />` in the generated html. It will produce invalid html, and may break the page layout.
115 ### <a name="Partial customisation, or adding"></a> Partial customisation, or adding in new features to an existing skin
117 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 & WYSIWYG buttons from view page, you create only a `view.yourlocal.tmpl`:
119 %TMPL:INCLUDE{"view"}%
120 %TMPL:DEF{"edit_topic_link"}%%TMPL:END%
121 %TMPL:DEF{"edit_wysiwyg_link"}%%TMPL:END%
123 and then set `SKIN=yourlocal,pattern`.
125 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 %USERSWEB%.TWikiPreferences for globally, or a Web's Webname.WebPreferences for a particular web)
127 ## <a name="Variables in Skins"></a> Variables in Skins
129 You can use [[template variables|Main/TWikiTemplates#TemplateVariables]], [[TWikiVariables]], and other predefined variables to compose your skins. Some commonly used variables in skins:
131 <table border="1" cellpadding="0" cellspacing="0">
133 <th bgcolor="#99CCCC"><strong> Variable: </strong></th>
134 <th bgcolor="#99CCCC"><strong> Expanded to: </strong></th>
137 <td><code>%WEBLOGONAME%</code></td>
138 <td> Filename of web logo </td>
141 <td><code>%WEBLOGOIMG%</code></td>
142 <td> Image URL of web logo </td>
145 <td><code>%WEBLOGOURL%</code></td>
146 <td> Link of web logo </td>
149 <td><code>%WEBLOGOALT%</code></td>
150 <td> Alt text of web logo </td>
153 <td><code>%WIKILOGOURL%</code></td>
154 <td> Link of page logo </td>
157 <td><code>%WIKILOGOIMG%</code></td>
158 <td> Image URL of page logo </td>
161 <td><code>%WIKILOGOALT%</code></td>
162 <td> Alt text of page logo </td>
165 <td><code>%WEBBGCOLOR%</code></td>
166 <td> Web-specific background color, defined in the [[Main/WebPreferences]]</td>
169 <td><code>%WIKITOOLNAME%</code></td>
170 <td> The name of your TWiki site </td>
173 <td><code>%SCRIPTURL%</code></td>
174 <td> The script URL of TWiki </td>
177 <td><code>%SCRIPTURLPATH%</code></td>
178 <td> The script URL path </td>
181 <td><code>%SCRIPTSUFFIX%</code></td>
182 <td> The script suffix, ex: <code>.pl</code>, <code>.cgi</code></td>
185 <td><code>%WEB%</code></td>
186 <td> The name of the current web. </td>
189 <td><code>%TOPIC%</code></td>
190 <td> The name of the current topic. </td>
193 <td><code>%WEBTOPICLIST%</code></td>
194 <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
197 <td><code>%TEXT%</code></td>
198 <td> The topic text, e.g. the content that can be edited </td>
201 <td><code>%META{"form"}%</code></td>
202 <td>[[Main/TWikiForms]], if any </td>
205 <td><code>%META{"attachments"}%</code></td>
206 <td>[[Main/FileAttachment]] table </td>
209 <td><code>%META{"parent"}%</code></td>
210 <td> The topic parent </td>
213 <td><code>%EDITTOPIC%</code></td>
217 <td><code>%REVTITLE%</code></td>
218 <td> The revision title, if any, ex: <code>(r1.6)</code></td>
221 <td><code>%REVINFO%</code></td>
222 <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
225 <td><code>%WEBCOPYRIGHT%</code></td>
226 <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
229 <td><code>%BROADCASTMESSAGE%</code></td>
230 <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>
236 ## <a name="The "Go" Box and Navigation Box"></a> The "Go" Box and Navigation Box
238 The default skins include a [["Go" box|Main/GoBox]], also called "Jump" box, to jump to a topic.
240 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.
242 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:
244 <form action="http://www.dementia.org/twiki/view/%WEB%/%TOPIC%" name="sample">
245 <table bgcolor="#DDDDDD" border="0" cellpadding="5">
247 <td colspan="2"> Bare bones header, for demo only </td>
251 <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">...</option>
252 <option value="http://twiki.org/">Intranet home</option>
253 <option value="%USERSWEB%.TWikiUsers">Employee index</option>
254 <option value="%USERSWEB%.WebHome">%USERSWEB% web</option>
255 <option value="%SYSTEMWEB%.WebHome">%SYSTEMWEB% web</option>
256 <option value="http://www.google.com/">Google</option>
257 <option value="http://www.yahoo.com/">Yahoo!</option></select></td>
261 <td><input name="topic" size="16" type="text" /></td>
266 **_Note:_** Redirect to a URL only works if it is enabled in `configure` (Miscellaneous, `{AllowRedirectUrl}`).
268 ## <a name="Using Cascading Style Sheets"></a> Using Cascading Style Sheets
270 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`.
272 - To see how CSS is used in the default TWiki skin, see: [[PatternSkin]]
273 - If you write a complete new skin, this is the syntax to use in a template file:
275 <style type='text/css' media='all'>@import url('%PUBURLPATH%/%SYSTEMWEB%/MySkin/mystyle.css');</style>
277 ## <a name="Attachment Tables"></a> Attachment Tables
279 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.
281 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:
283 <table border="1" cellpadding="0" cellspacing="0">
285 <th bgcolor="#99CCCC"><strong> Macro </strong></th>
286 <th bgcolor="#99CCCC"><strong> Description </strong></th>
289 <td><code>ATTACH:files:header</code></td>
290 <td> Standard title bar </td>
293 <td><code>ATTACH:files:row</code></td>
294 <td> Standard row </td>
297 <td><code>ATTACH:files:footer</code></td>
298 <td> Footer for all screens </td>
301 <td><code>ATTACH:files:header:A</code></td>
302 <td> Title bar for upload screens, with attributes column </td>
305 <td><code>ATTACH:files:row:A</code></td>
306 <td> Row for upload screen </td>
309 <td><code>ATTACH:files:footer:A</code></td>
310 <td> Footer for all screens </td>
314 The format of tables of file versions in the Upload screen can also be changed, using the macros:
316 <table border="1" cellpadding="0" cellspacing="0">
318 <th bgcolor="#99CCCC"><strong> Macro </strong></th>
319 <th bgcolor="#99CCCC"><strong> Description </strong></th>
322 <td><code>ATTACH:versions:header</code></td>
323 <td> Header for versions table on upload screen </td>
326 <td><code>ATTACH:versions:row</code></td>
327 <td> Row format for versions table on upload screen </td>
330 <td><code>ATTACH:versions:footer</code></td>
331 <td> Footer for versions table on upload screen </td>
335 The `ATTACH:row` macros are expanded for each file in the attachment table, using the following special tags:
337 <table border="1" cellpadding="0" cellspacing="0">
339 <th bgcolor="#99CCCC"><strong> Tag </strong></th>
340 <th bgcolor="#99CCCC"><strong> Description </strong></th>
343 <td><code>%A_URL%</code></td>
344 <td><code>viewfile</code> URL that will recover the file </td>
347 <td><code>%A_REV%</code></td>
348 <td> Revision of this file </td>
351 <td><code>%A_ICON%</code></td>
352 <td> A file icon suitable for representing the attachment content </td>
355 <td><code>%A_FILE%</code></td>
356 <td> The name of the file. To get the 'pub' url of the file, use <code>%PUBURL%/%WEB%/%TOPIC%/%A_FILE%</code></td>
359 <td><code>%A_SIZE%</code></td>
360 <td> The size of the file </td>
363 <td><code>%A_DATE%</code></td>
364 <td> The date the file was uploaded </td>
367 <td><code>%A_USER%</code></td>
368 <td> The user who uploaded it </td>
371 <td><code>%A_COMMENT%</code></td>
372 <td> The comment they put in when uploading it </td>
375 <td><code>%A_ATTRS%</code></td>
376 <td> The attributes of the file as seen on the upload screen e.g "h" for a hidden file </td>
380 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
382 See TWiki:Plugins/SkinPackagingHowTo and TWiki:Plugins/SkinDeveloperFAQ
384 ## <a name="Browsing Installed Skins"></a> Browsing Installed Skins
386 You can try out all installed skins in the [[TWikiSkinBrowser]].
388 ## <a name="Activating Skins"></a> Activating Skins
390 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.
392 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`.
394 The basic skin is defined by a `SKIN` setting:
396 - `Set SKIN = catskin, bearskin`
398 You can also add a parameter to the URL, such as `?skin=catskin,bearskin`:
400 - [[http://www.dementia.org/twiki/view/%WEB%/%TOPIC%?skin=catskin,bearskin|%WEB%/%TOPIC%?skin=catskin,bearskin]]
402 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_.
404 - `Set COVER = ruskin`
406 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.
408 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.
410 The full skin path is built up as follows: `SKIN` setting (or `?skin` if it is set), then `COVER` setting is added, then `?cover`.
412 <a name="HardCodedSkins"></a>
414 ## <a name="Hard-Coded Skins"></a> Hard-Coded Skins
416 The `text` skin is reserved for TWiki internal use.
418 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`.
420 **_Related Topics:_** [[TWikiSkinBrowser]], [[AdminDocumentationCategory]], [[DeveloperDocumentationCategory]], TWiki:TWiki.TWikiSkinsSupplement
422 -- **_Contributors:_** TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.CrawfordCurrie