1 # <a name="%SYSTEMWEB%._PatternSkin Customi"></a><a name=" %SYSTEMWEB%._PatternSkin Custom"></a> %SYSTEMWEB%.PatternSkin Customization
3 **Questions and answers on configuring page elements.** For styling your TWiki, see [[PatternSkinCssCookbook]].
7 <li><a href="#First Read: How to modify _Patt"> First Read: How to modify PatternSkin templates</a><ul>
8 <li><a href="#The template approach"> The template approach</a></li>
9 <li><a href="#The topic template approach (usi"> The topic template approach (using VIEW_TEMPLATE)</a></li>
12 <li><a href="#Reference: pattern skin template"> Reference: pattern skin template INCLUDE tree</a></li>
13 <li><a href="#Logo"> Logo</a><ul>
14 <li><a href="#How can I change the web logo?"> How can I change the web logo?</a></li>
15 <li><a href="#How do I set a site-wide logo?"> How do I set a site-wide logo?</a></li>
16 <li><a href="#My logo does not fit the top bar"> My logo does not fit the top bar</a></li>
17 <li><a href="#I want to change the white space"> I want to change the white space above and below the logo</a></li>
20 <li><a href="#Top bar"> Top bar</a><ul>
21 <li><a href="#The search box won't find topics"> The search box won't find topics in other webs</a></li>
22 <li><a href="#I want to change the height of t"> I want to change the height of the top bar</a></li>
23 <li><a href="#I want to set or change the top"> I want to set or change the top background image</a></li>
24 <li><a href="#I want to have the web color in"> I want to have the web color in the top bar</a></li>
25 <li><a href="#I want to remove the Jump and Se"> I want to remove the Jump and Search boxes from the top bar </a></li>
26 <li><a href="#I want to hide the top bar"> I want to hide the top bar</a></li>
29 <li><a href="#Left bar"> Left bar</a><ul>
30 <li><a href="#I want to hide the left bar"> I want to hide the left bar</a></li>
31 <li><a href="#I want to make the left bar wide"> I want to make the left bar wider</a></li>
34 <li><a href="#Other page parts"> Other page parts</a><ul>
35 <li><a href="#I want to hide the edit buttons"> I want to hide the edit buttons from certain users</a></li>
36 <li><a href="#I want to remove the History but"> I want to remove the History button from the bottom</a></li>
37 <li><a href="#I want to insert text outside of"> I want to insert text outside of the topic content</a></li>
38 <li><a href="#I want to place the form at the"> I want to place the form at the top</a></li>
39 <li><a href="#I only want to show the WYSIWYG"> I only want to show the WYSIWYG button on explicit pages</a></li>
45 ## <a name="First Read: How to modify _Patte"></a> First Read: How to modify PatternSkin templates
47 Everything you see on the common 'view' page is written by the `view` template. For pattern skin this file is `/templates/view.pattern.tmpl`.
49 We describe two approaches to override this template:
51 1. By creating a custom skin file in the `templates` directory
52 2. By creating a custom topic template
54 Which approach is best?
56 - If you want to change the appearance for a lot of pages or even site-wide, the template approach is the easiest.
57 - If you want to change the appearance of a single topic, or a set of topics, use a topic template.
59 ### <a name="The template approach"></a> The template approach
61 To change templates you will need shell access. If you don't have this read on below in [[The topic template approach|Main/WebHome#TopicTemplates]].
63 The quickest way to change the view template would be to simply change the text in the template. A safer way - strongly recommended, because it will survive a TWiki update - is to create your own custom skin. That may sound like an awful lot of work, but in reality a skin may be as much as 1 file that consists of only a few lines of code.
65 **Example** %BR% Let's say you want to simplify the bottom toolbar and remove all links except for "More topic actions". You would need to target `%TMPL:DEF{"topicactionbuttons"}%`, which is located in `view.pattern.tmpl`.
67 **The steps you would need:**
69 1. Think up a name for your skin. Let us use `myskin` for now.
70 2. Create a new (empty) view template file in `/templates` called `view.myskin.tmpl`.
71 3. In `view.myskin.tmpl` you write:
72 > %TMPL:INCLUDE{"view"}%
73 > %TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"activatable_more"}%%TMPL:END%
74 4. For testing, view any topic and append to the topic name: `?cover=myskin`. You should see an effect now.
75 5. To make the changes visible on all pages, go to [[Main.TWikiPreferences|Main/TWikiPreferences]] (to keep [[TWikiPreferences]] intact) and write:
77 > * Set COVER = myskin
81 > * Set SKIN = myskin,pattern
83 Test by appending `?cover=myskin` to the url.
85 <a name="TopicTemplates"></a>
87 ### <a name="The topic template approach (usi"></a> The topic template approach (using VIEW\_TEMPLATE)
89 Template overrides can be written in a topic, a so-called _topic template_. Topic template names end with `Template`, for instance `BlogPostViewTemplate`.
91 Call this template by setting `VIEW_TEMPLATE`:
93 > * Set VIEW_TEMPLATE = BlogPostView
95 - Note that you don't use the `Template` extension now
96 - You can make this setting hidden by writing this in the Settings screen: go to More and then Topic Settings
97 - On topic creation you can set the topic template by passing `templatetopic`:
98 <input type="hidden" name="templatetopic" value="BlogPostViewTemplate" />
100 We can use the same example as above. In a topic write:
102 > %TMPL:INCLUDE{"view"}%
103 > %TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"activatable_more"}%%TMPL:END%
105 You can also test this by appending `?template=PersonalInfoView` to the url.
107 ## <a name="Reference: pattern skin template"></a> Reference: pattern skin template INCLUDE tree
117 %SYSTEMWEB%.WebTopBar
121 viewtopicactionbuttons
123 %SYSTEMWEB%.WebBottomBar
125 ## <a name="Logo"></a> Logo
127 ### <a name="How can I change the web logo?"></a> How can I change the web logo?
129 By default the logo at the top left of each web points to the image with name `logo.gif` that is attached to each web's [[WebPreferences]]. <br /> The default variables that cause this behavior are defined in [[TWikiPreferences]].
131 Redefine your custom variables in [[Main.TWikiPreferences|Main/TWikiPreferences]] (to keep [[TWikiPreferences]] intact):
133 > * Set WEBLOGONAME = logo.gif
134 > * Set WEBLOGOIMG = %PUBURLPATH%/%BASEWEB%/%WEBPREFSTOPIC%/%WEBLOGONAME%
135 > * Set WEBLOGOURL = %SCRIPTURLPATH{"view"}%/%BASEWEB%/%HOMETOPIC%
136 > * Set WEBLOGOALT = Home
138 There are 2 ways to change the logo in a web:
142 > - Create a new image named `logo.gif` and attach it to the web's [[WebPreferences]] topic. %SYSTEMWEB%.PatternSkin's stylesheet assumes the logo is 40px high. More about that later.
143 > - You can also upload the image with FTP to `/pub/YourWeb/WebPreferences/`.
144 > - Copy the above instructions ("Redefine your custom variables") and insert your logo name.
146 **Using a new filename:**
148 > - Attach whatever image and attach it to the web's [[WebPreferences]] topic. Then add to the [[WebPreferences]] (under _Custom web preferences_):
150 > * Set WEBLOGONAME = your-logo-name.gif-or-png
152 > - Copy the above instructions ("Redefine your custom variables") and insert your logo name.
154 ### <a name="How do I set a site-wide logo?"></a> How do I set a site-wide logo?
156 There is a bunch of site-wide logo variables in [[Main.TWikiPreferences|Main/TWikiPreferences]]: `WIKILOGOIMG`, `WIKILOGOURL` and `WIKILOGOALT`. To change only the web logo image to site-wide, in [[Main.TWikiPreferences|Main/TWikiPreferences]] set:
158 > * Set WEBLOGOIMG = %WIKILOGOIMG%
160 ### <a name="My logo does not fit the top bar"></a> My logo does not fit the top bar
162 See [[I want to change the height of the top bar|Main/WebHome#TopBarChangeHeight]]
164 ### <a name="I want to change the white space"></a> I want to change the white space above and below the logo
166 Change the table style in topic %SYSTEMWEB%.WebTopBar. The default top padding is 11px.
168 ## <a name="Top bar"></a> Top bar
170 ### <a name="The search box won't find topics"></a> The search box won't find topics in other webs
172 In [[WebTopBar]] you can find the line:
174 <input type="hidden" name="web" value="%BASEWEB%" />
176 To search all webs, write:
178 > <input type="hidden" name="web" value="all" />
180 To search a couple of webs, for instance the webs Main and TWiki, write:
182 > <input type="hidden" name="web" value="Main,TWiki" />
184 See also: [[Search variable|TWiki/VarSEARCH]]
186 <a name="TopBarChangeHeight"></a>
188 ### <a name="I want to change the height of t"></a> I want to change the height of the top bar
190 The top bar is 64 pixels high by default.
192 **Using templates:** %BR% Using either a template or a topic template, copy this definition in your custom template:
194 > %TMPL:DEF{"topbardimensions"}%
196 > #patternClearHeaderCenter,
197 > #patternClearHeaderLeft,
198 > #patternClearHeaderRight,
199 > #patternTopBarContentsOuter {
200 > height:64px; /* top bar height; make room for header columns */
205 > And change the number from 64px to a different value.
207 **Using style sheets:**
209 > Create a new stylesheet with above definition in it, attach it to a topic and point
213 > to that topic attachment. See %SYSTEMWEB%.PatternSkinCssCookbook about creating custom styles.
215 ### <a name="I want to set or change the top"></a><a name="I want to set or change the top "></a> I want to set or change the top background image
217 The image at the top is called "header art" - commonly the top image found on blog sites. The image that is displayed by default is set by the variable `WEBHEADERART`, defined in [[TWikiPreferences]].
219 Redefine your custom variables in [[Main.TWikiPreferences|Main/TWikiPreferences]] (to keep [[TWikiPreferences]] intact):
221 > * Set WEBHEADERART = %PUBURLPATH%/%SYSTEMWEB%/PatternSkin/TWiki_header.gif
222 > * Set WEBHEADERBGCOLOR = somehexcolor (no quotes, for example: #ffffff)
224 You can also set `WEBHEADERART` per web, by defining the variable in the Web's WebPreferences.
226 ### <a name="I want to have the web color in"></a><a name="I want to have the web color in "></a> I want to have the web color in the top bar
228 Redefine `WEBHEADERBGCOLOR` in [[Main.TWikiPreferences|Main/TWikiPreferences]] (to keep [[TWikiPreferences]] intact):
230 > * Set WEBHEADERBGCOLOR = %WEBBGCOLOR%
232 ### <a name="I want to remove the Jump and Se"></a> I want to remove the Jump and Search boxes from the top bar
234 If you have localization enabled, you will also see a language dropdown box at the far right.
236 You can remove these items from %SYSTEMWEB%.WebTopBar.
238 ### <a name="I want to hide the top bar"></a> I want to hide the top bar
242 The view template is populated with page elements using template inclusions:
244 %TMPL:INCLUDE{"page"}%
245 %TMPL:INCLUDE{"viewtopbar"}%
246 %TMPL:INCLUDE{"viewtoolbar"}%
247 %TMPL:INCLUDE{"viewleftbar"}%
248 %TMPL:INCLUDE{"viewrightbar"}%
249 %TMPL:INCLUDE{"viewtopicactionbuttons"}%
250 %TMPL:INCLUDE{"viewbottombar"}%
252 Each included template draws a part of the screen.%BR% Omit `%TMPL:INCLUDE{"viewtopbar"}%` to hide the top bar.
254 Another approach is to clear the contents of module `topbar`. Using either a template or a topic template, write in your custom template:
256 > %TMPL:INCLUDE{"view"}%
257 > %TMPL:INCLUDE{"topbar"}%%TMPL:END%
261 > %TMPL:DEF{"topbardimensions"}%#patternTopBar,
262 > #patternClearHeaderCenter,
263 > #patternClearHeaderLeft,
264 > #patternClearHeaderRight,
265 > #patternTopBarContentsOuter {
269 **Using style sheets:** %BR% See [[PatternSkinCssCookbookNoTopBar]]
271 ## <a name="Left bar"></a> Left bar
273 ### <a name="I want to hide the left bar"></a> I want to hide the left bar
275 **Using templates:** %BR% Omit `%TMPL:INCLUDE{"viewleftbar"}%` to hide the left bar, or in a custom template clear it using
277 > %TMPL:DEF{"viewleftbar"}%%TMPL:END%
279 **Using style sheets:** %BR% See [[PatternSkinCssCookbookNoLeftBar]]
281 ### <a name="I want to make the left bar wide"></a> I want to make the left bar wider
283 **Using templates:** %BR%
285 The left bar is 12 em wide by default.
287 **Using templates:** %BR% Using either a template or a topic template, copy this definition in your custom template:
289 > %TMPL:DEF{"leftbardimensions"}%#patternOuter {
297 > And change the number from 12em to a different value (3 occurrences).
299 ## <a name="Other page parts"></a> Other page parts
301 ### <a name="I want to hide the edit buttons"></a><a name="I want to hide the edit buttons "></a> I want to hide the edit buttons from certain users
303 It may defy the wiki-ness of your TWiki installation, but in certain circumstances it could be useful to hide the edit buttons from users that are not logged in, for instance for clients that have gotten viewing rights only.
305 Using either a template or a topic template, 'empty' `topicaction` and `toolbar` by writing:
307 > %TMPL:INCLUDE{"view"}%
308 > %TMPL:DEF{"topicaction"}%%TMPL:END%
309 > %TMPL:DEF{"toolbar"}%%TMPL:END%
311 In the user page of %USERSWEB%.TWikiGuest, set the cover to
313 > * Set COVER = customer
315 By default this topic is editable only by TWiki admins.
317 ### <a name="I want to remove the History but"></a> I want to remove the History button from the bottom
319 All action buttons are defined in `viewtopicactionbuttons.pattern.tmpl`. The history buttons or in module `revisions`:
321 > <code> %TMPL:DEF\{"topicactionbuttons"\}%%TMPL:P\{"activatable\_raw\_edit"\}%%TMPL:P\{"sep"\}% %TMPL:P\{context="WysiwygPluginEnabled" then="activatable\_edit\_wysiwyg"\}% %TMPL:P\{context="WysiwygPluginEnabled" then="sep"\}% %TMPL:P\{"activatable\_attach"\}%%TMPL:P\{"sep"\}% %TMPL:P\{"printable"\}%%TMPL:P\{"sep"\}% %TMPL:P\{"raw"\}%%TMPL:P\{"sep"\}% %TMPL:P\{"backlinks"\}%%TMPL:P\{"sep"\}% %TMPL:P\{"revisions"\}%%TMPL:P\{"sep"\}% <span><font>< HERE</font></span> %TMPL:P\{"activatable\_more"\}%%TMPL:END% </code>
323 If we emptied module `revisions` we would end up with 2 separators, so we need to remove the line altogether. We do this by copying the block and omitting the line. %BR% Using either a template or a topic template, to remove the history buttons write in your custom template:
325 > %TMPL:INCLUDE{"view"}%
327 > %TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"activatable_raw_edit"}%%TMPL:P{"sep"}%
328 > %TMPL:P{context="WysiwygPluginEnabled" then="activatable_edit_wysiwyg"}%
329 > %TMPL:P{context="WysiwygPluginEnabled" then="sep"}%
330 > %TMPL:P{"activatable_attach"}%%TMPL:P{"sep"}%
331 > %TMPL:P{"printable"}%%TMPL:P{"sep"}%
332 > %TMPL:P{"raw"}%%TMPL:P{"sep"}%
333 > %TMPL:P{"backlinks"}%%TMPL:P{"sep"}%
334 > %TMPL:P{"activatable_more"}%%TMPL:END%
336 > Remove all newlines if you copy-paste above text.
338 ### <a name="I want to insert text outside of"></a> I want to insert text outside of the topic content
340 PatternSkin has 2 'buckets' to write additional content to: `beforetextcontents` and `aftertextcontents`, both defined in `view.pattern.tmpl`. These containers can contain text or html and are placed directly before and after the topic text.
342 Both modules are wrapped in CSS containers:
344 - `beforetextcontents` - wrapped in `div` of class `twikiBeforeText`
345 - `aftertextcontents` - wrapped in `div` of class `twikiAfterText`
347 To put contents **before** the main text, use the custom skin approach as described above.%BR% So our custom template contains:
349 > %TMPL:INCLUDE{"view"}%
350 > %TMPL:DEF{"beforetextcontents"}%This is the text before%TMPL:END%
352 Use the same procedure for contents to be put **after** the topic text:
354 > %TMPL:INCLUDE{"view"}%
355 > %TMPL:DEF{"aftertextcontents"}%This is the text after%TMPL:END%
357 ### <a name="I want to place the form at the"></a><a name="I want to place the form at the "></a> I want to place the form at the top
359 Pattern skin has 2 buckets for the form: `formattop` (form-at-the-top) and `formatbottom` (form-at-the-bottom):
361 > %TMPL:DEF{"formattop"}%%TMPL:END%
362 > %TMPL:DEF{"formatbottom"}%%TMPL:P{"form"}%%TMPL:END%
364 You simply swap the bucket contents. Using either a template or a topic template, write in your custom template:
366 > %TMPL:INCLUDE{"view"}%
367 > %TMPL:DEF{"formattop"}%%TMPL:P{"form"}%%TMPL:END%
368 > %TMPL:DEF{"formatbottom"}%%TMPL:END%
370 ### <a name="I only want to show the WYSIWYG"></a><a name="I only want to show the WYSIWYG "></a> I only want to show the WYSIWYG button on explicit pages
372 In [[Main.TWikiPreferences|Main/TWikiPreferences]], set `COMPOSER` to a blank value:
376 In the topic, set the `COMPOSER` variable to `kupu`:
378 > * Set COMPOSER = kupu