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 </td>
71   </tr>
72   <tr>
73     <td><code>%WEBURLENCODED%</code></td>
74     <td> The name of the current web, URL encoded (for form action) </td>
75   </tr>
76   <tr>
77     <td><code>%TOPIC%</code></td>
78     <td> The name of the current topic </td>
79   </tr>
80   <tr>
81     <td><code>%TOPICURLENCODED%</code></td>
82     <td> The name of the current topic, URL encoded (for form action) </td>
83   </tr>
84   <tr>
85     <td><code>%WEBTOPICLIST%</code></td>
86     <td> Common links of current web, defined in the [[Main/WebPreferences]]. It includes a [[Main/WebHome#GoBox]]</td>
87   </tr>
88   <tr>
89     <td><code>%TEXT%</code></td>
90     <td> The topic text, e.g. the content that can be edited </td>
91   </tr>
92   <tr>
93     <td><code>%META{"form"}%</code></td>
94     <td>[[Main/TWikiForms]], if any </td>
95   </tr>
96   <tr>
97     <td><code>%META{"attachments"}%</code></td>
98     <td>[[Main/FileAttachment]] table </td>
99   </tr>
100   <tr>
101     <td><code>%META{"parent"}%</code></td>
102     <td> The topic parent </td>
103   </tr>
104   <tr>
105     <td><code>%EDITTOPIC%</code></td>
106     <td> Edit link </td>
107   </tr>
108   <tr>
109     <td><code>%REVTITLE%</code></td>
110     <td> The revision title, if any, ex: <code>(r1.6)</code></td>
111   </tr>
112   <tr>
113     <td><code>%REVINFO%</code></td>
114     <td> Revision info, ex: <code>r1.6 - 24 Dec 2002 - 08:12 GMT - Main.admin</code></td>
115   </tr>
116   <tr>
117     <td><code>%WEBCOPYRIGHT%</code></td>
118     <td> Copyright notice, defined in the [[Main/WebPreferences]]</td>
119   </tr>
120 </table>
121
122 <a name="GoBox"></a>
123
124 ### <a name="The &quot;Go&quot; Box and Navigation Box"></a> The "Go" Box and Navigation Box
125
126 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.
127
128 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:
129
130 <form action="http://www.dementia.org/twiki//view/%WEBURLENCODED%/%TOPICURLENCODED%" name="sample">
131   <table border="3">
132     <tr>
133       <td><select name="sel" onchange="this.form.topic.value=this.options[this.selectedIndex].value; this.form.submit()"><option selected value="">Navigate...</option>
134           <option value="http://www.twiki.org/">Intranet home</option>
135           <option value="Main.TWikiUsers">Employee index</option>
136           <option value="Main.WebHome">Main web</option>
137           <option value="TWiki.WebHome">TWiki web</option>
138           <option value="http://www.google.com/">Google</option>
139           <option value="http://www.yahoo.com/">Yahoo!</option></select> Bare bones header for demo only </td>
140     </tr>
141     <tr>
142       <td> %WEBTOPICLIST% </td>
143     </tr>
144   </table>
145 </form>
146
147 ## <a name="Packaging and Publishing Skins"></a> Packaging and Publishing Skins
148
149 See TWiki:Plugins/SkinPackagingHowTo
150
151 ## <a name="Activating Skins"></a> Activating Skins
152
153 A skin can be activated in two ways:
154
155 - Define the `SKIN` Preference variable in [[TWikiPreferences]], one of the [[WebPreferences]], or in a user - Main.admin - topic.
156   - `Set SKIN = print`
157
158 - Add `?skin=name` to the URL, for this example:
159   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=print> (for the print view skin)
160   - <http://www.dementia.org/twiki//view/%WEB%/%TOPIC%?skin=plain> (for the plain view skin that has no header and footer)
161
162 The <code>**?skin=name**</code> URL parameter overrides the SKIN Preference value.
163
164 -- [[PeterThoeny]] - 03 Jan 2003