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="#Packaging and Publishing Skins"> Packaging and Publishing Skins</a></li>
11         <li><a href="#Activating Skins"> Activating Skins</a></li>
12       </ul>
13     </li>
14   </ul>
15 </div>
16
17 # <a name="TWiki Skins"></a> TWiki Skins
18
19 _Skins overlay regular templates with alternate header/footer layouts; topic text is not affected_
20
21 ## <a name="Overview"></a> Overview
22
23 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.
24
25 ## <a name="Defining Skins"></a> Defining Skins
26
27 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`.
28
29 Use the existing [[TWikiTemplates]] (like `view.tmpl`) or skin files as a base for your own skin, name it for example `view.myskin.tmpl`.
30
31 ## <a name="Variables in Skins"></a> Variables in Skins
32
33 You can use [[template variables|Main/TWikiTemplates#TemplateVariables]], [[TWikiVariables]], and other predefined variables to compose your skins. Some commonly used variables in skins:
34
35 <table border="1" cellpadding="0" cellspacing="0">
36   <tr>
37     <th bgcolor="#99CCCC"><strong> Variable: </strong></th>
38     <th bgcolor="#99CCCC"><strong> Expanded to: </strong></th>
39   </tr>
40   <tr>
41     <td><code>%WIKILOGOURL%</code></td>
42     <td> Link of page logo </td>
43   </tr>
44   <tr>
45     <td><code>%WIKILOGOIMG%</code></td>
46     <td> Image URL of page logo </td>
47   </tr>
48   <tr>
49     <td><code>%WIKILOGOALT%</code></td>
50     <td> Alt text of page logo </td>
51   </tr>
52   <tr>
53     <td><code>%WEBBGCOLOR%</code></td>
54     <td> Web specific background color, defined in the [[Main/WebPreferences]]</td>
55   </tr>
56   <tr>
57     <td><code>%WIKITOOLNAME%</code></td>
58     <td> The name of your TWiki site </td>
59   </tr>
60   <tr>
61     <td><code>%SCRIPTURL%</code></td>
62     <td> The script URL of TWiki </td>
63   </tr>
64   <tr>
65     <td><code>%SCRIPTSUFFIX%</code></td>
66     <td> The script suffix, ex: <code>.pl</code>, <code>.cgi</code></td>
67   </tr>
68   <tr>
69     <td><code>%WEB%</code></td>
70     <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>
71   </tr>
72   <tr>
73     <td><code>%TOPIC%</code></td>
74     <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>
75   </tr>
76   <tr>
77     <td><code>%WEBTOPICLIST%</code></td>
78     <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
79   </tr>
80   <tr>
81     <td><code>%TEXT%</code></td>
82     <td> The topic text, e.g. the content that can be edited </td>
83   </tr>
84   <tr>
85     <td><code>%META{"form"}%</code></td>
86     <td>[[Main/TWikiForms]], if any </td>
87   </tr>
88   <tr>
89     <td><code>%META{"attachments"}%</code></td>
90     <td>[[Main/FileAttachment]] table </td>
91   </tr>
92   <tr>
93     <td><code>%META{"parent"}%</code></td>
94     <td> The topic parent </td>
95   </tr>
96   <tr>
97     <td><code>%EDITTOPIC%</code></td>
98     <td> Edit link </td>
99   </tr>
100   <tr>
101     <td><code>%REVTITLE%</code></td>
102     <td> The revision title, if any, ex: <code>(r1.6)</code></td>
103   </tr>
104   <tr>
105     <td><code>%REVINFO%</code></td>
106     <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
107   </tr>
108   <tr>
109     <td><code>%WEBCOPYRIGHT%</code></td>
110     <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
111   </tr>
112 </table>
113
114 <a name="GoBox"></a>
115
116 ### <a name="The &quot;Go&quot; Box and Navigation Box"></a> The "Go" Box and Navigation Box
117
118 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.
119
120 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:
121
122 <form action="http://www.dementia.org/twiki//view/%WEB%/%TOPIC%" name="sample">
123   <table border="3">
124     <tr>
125       <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">Navigate...</option>
126           <option value="http://www.twiki.org/">Intranet home</option>
127           <option value="Main.TWikiUsers">Employee index</option>
128           <option value="Main.WebHome">Main web</option>
129           <option value="TWiki.WebHome">TWiki web</option>
130           <option value="http://www.google.com/">Google</option>
131           <option value="http://www.yahoo.com/">Yahoo!</option></select> Bare bones header for demo only </td>
132     </tr>
133     <tr>
134       <td> %WEBTOPICLIST% </td>
135     </tr>
136   </table>
137 </form>
138
139 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
140
141 See TWiki:Plugins/SkinPackagingHowTo
142
143 ## <a name="Activating Skins"></a> Activating Skins
144
145 A skin can be activated in two ways:
146
147 - Define the `SKIN` Preference variable in [[TWikiPreferences]], one of the [[WebPreferences]], or in a user - Main.admin - topic.
148   - `Set SKIN = print`
149
150 - Add `?skin=name` to the URL, for this example:
151   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=print> (for the print view skin)
152   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=plain> (for the plain view skin that has no header and footer)
153
154 The <code>**?skin=name**</code> URL parameter overrides the SKIN Preference value.
155
156 -- [[PeterThoeny]] - 05 Jan 2003