1
%META:TOPICINFO{author="ProjectContributor" date="1130019100" format="1.1" version="1"}%
3
---+!! %SYSTEMWEB%.PatternSkin Customization
5
*Guidelines how to create and customize page templates.* For styling your Foswiki using stylesheets, see PatternSkinCssCookbook.
9
---++ First Read: How to modify !PatternSkin templates
11
Everything you see on the common 'view' page is written by the =view= template. For pattern skin this file is =/templates/view.pattern.tmpl=.
13
We describe two approaches to override this template:
14
1 By creating a custom skin file in the =templates= directory
15
1 By creating a custom topic template
17
Which approach is best?
18
* If you want to change the appearance for a lot of pages or even site-wide, the template approach is the easiest.
19
* If you want to change the appearance of a single topic, or a set of topics, use a topic template.
21
---+++ The template approach
23
To change templates you will need shell access. If you don't have this read on below in [[#TopicTemplates][The topic template approach]].
25
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 Foswiki 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.
28
Let's say you want to simplify the bottom toolbar and remove all links except for "More topic actions". You would need to target =%<nop>TMPL:DEF{"topicactionbuttons"}%=, which is located in =view.pattern.tmpl=.
30
*The steps you would need:*
31
1 Think up a name for your skin. Let us use =myskin= for now.
32
1 Create a new (empty) view template file in =/templates= called =view.myskin.tmpl=.
33
1 In =view.myskin.tmpl= you write:
34
<blockquote><verbatim>
35
%TMPL:INCLUDE{"view"}%
36
%TMPL:DEF{"top:topicactionbuttons"}%%TMPL:P{"more_link"}%%TMPL:END%</verbatim></blockquote>
37
1 For testing, view any topic and append to the topic name: =?cover=myskin=. You should see an effect now.
38
1 To make the changes visible on all pages, go to [[%USERSWEB%.SitePreferences]] (to keep %WIKIPREFSTOPIC% intact) and write:
40
* <nop>Set COVER = myskin
44
* <nop>Set SKIN = myskin,pattern
47
Test by appending =?cover=myskin= to the url.
51
---+++ The topic template approach (using VIEW_TEMPLATE)
53
Template overrides can be written in a topic, a so-called _topic template_. Topic template names end with =Template=, for instance =BlogPostViewTemplate=.
55
Call this template by setting =VIEW_TEMPLATE=:
58
* Set VIEW_TEMPLATE = BlogPostView
61
* Note that you don't use the =Template= extension now
62
* You can make this setting hidden by writing this in the Settings screen: go to More and then Topic Settings
63
* On topic creation you can set the topic template by passing =templatetopic=:
65
<input type="hidden" name="templatetopic" value="BlogPostViewTemplate" />
68
We can use the same example as above. In a topic write:
71
%TMPL:INCLUDE{"view"}%
72
%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"more_link"}%%TMPL:END%
76
You can also test this by appending =?template=PersonalInfoView= to the url.
78
---++ Reference: pattern skin template INCLUDE tree
80
The =view= script invokes the =view= template:
89
viewtopicactionbuttons
91
%SYSTEMWEB%.WebBottomBar
96
---+++ How can I change the web logo?
98
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 />
99
The [[%SYSTEMWEB%.PreferenceSettings][preference settings]] that cause this behavior are defined in [[%WIKIPREFSTOPIC%]].
101
Redefine your custom [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in [[%LOCALSITEPREFS%]] (to keep %WIKIPREFSTOPIC% intact):
103
* Set <nop>WEBLOGONAME = logo.gif
104
* Set <nop>WEBLOGOIMG = %<nop>PUBURLPATH%/%<nop>BASEWEB%/%<nop>WEBPREFSTOPIC%/%<nop>WEBLOGONAME%
105
* Set <nop>WEBLOGOURL = %<nop>SCRIPTURLPATH{"view"}%/%<nop>BASEWEB%/%<nop>HOMETOPIC%
106
* Set <nop>WEBLOGOALT = Home
109
There are 2 ways to change the logo in a web:
113
* 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.
114
* You can also upload the image with FTP to =/pub/YourWeb/WebPreferences/=.
115
* Copy the above instructions ("Redefine your custom preference settings") and insert your logo name.
117
*Using a new filename:*
119
* Attach whatever image and attach it to the web's WebPreferences topic. Then add to the WebPreferences (under _Custom web preferences_):
121
* Set <nop>WEBLOGONAME = your-logo-name.gif-or-png
123
* Copy the above instructions ("Redefine your custom preference settings") and insert your logo name.
126
---+++ How do I set a site-wide logo?
128
There are a bunch of site-wide logo [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in [[%LOCALSITEPREFS%]]: =WIKILOGOIMG=, =WIKILOGOURL= and =WIKILOGOALT=.
129
To change only the web logo image to site-wide, in [[%LOCALSITEPREFS%]] set:
131
* Set <nop>WEBLOGOIMG = %<nop>WIKILOGOIMG%
134
---+++ My logo does not fit the top bar
136
See [[#TopBarChangeHeight][I want to change the height of the top bar]]
138
---+++ I want to change the white space above and below the logo
140
Change the table style in topic %SYSTEMWEB%.WebTopBar. The default top padding is 11px.
144
---+++ The search box won't find topics in other webs
146
In %SYSTEMWEB%.WebTopBar you can find the line:
148
<input type="hidden" name="web" value="%BASEWEB%" />
151
To search all webs, write:
154
<input type="hidden" name="web" value="all" />
158
To search a couple of webs, for instance the webs Main and System, write:
161
<input type="hidden" name="web" value="Main,System" />
165
See also: [[%SYSTEMWEB%.VarSEARCH][Search macro]]
168
---+++ I want to change the height of the top bar
170
_This information has moved to [[PatternSkinCssCookBook#HeightTopBar][PatternSkinCssCookBook]]_
172
---+++ I want to set or change the top background image
174
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 preference =WEBHEADERART=, defined in [[%WIKIPREFSTOPIC%]].
176
Redefine your custom [[%SYSTEMWEB%.PreferenceSettings][preference settings]] in [[%LOCALSITEPREFS%]] (to keep %WIKIPREFSTOPIC% intact):
178
* <nop>Set WEBHEADERART = %<nop>PUBURLPATH%/%<nop>SYSTEMWEB%/PatternSkin/Foswiki_header.gif
179
* <nop>Set WEBHEADERBGCOLOR = somehexcolor (no quotes, for example: #ffffff)
182
You can also set =WEBHEADERART= per web, by setting the preference in the Web's !WebPreferences.
184
---+++ I want to have the web color in the top bar
186
Redefine =WEBHEADERBGCOLOR= in [[%LOCALSITEPREFS%]] (to keep %WIKIPREFSTOPIC% intact):
188
* <nop>Set WEBHEADERBGCOLOR = %<nop>WEBBGCOLOR%
191
---+++ I want to remove the Jump and Search boxes from the top bar
193
If you have localization enabled, you will also see a language dropdown box at the far right.
195
You can remove these items from %SYSTEMWEB%.WebTopBar.
197
---+++ I want to hide the top bar
201
The view template is populated with page elements using template inclusions:
204
%<nop>TMPL:INCLUDE{"view"}%
205
%<nop>TMPL:INCLUDE{"viewtopicactionbuttons"}%
206
%<nop>TMPL:INCLUDE{"viewtopbar"}%
207
%<nop>TMPL:INCLUDE{"viewsidebar"}%
210
Each included template draws a part of the screen.%BR%
211
Omit =%<nop>TMPL:INCLUDE{"viewtopbar"}%= to hide the top bar.
213
Another approach is to clear the contents of module =topbar= with an empty definition. Using either a template or a topic template, write in your custom template:
215
<blockquote><verbatim>
216
%TMPL:INCLUDE{"view"}%
217
%TMPL:DEF{"topbar"}%%TMPL:END%
223
%TMPL:DEF{"topbardimensions"}%#patternTopBar,
224
#patternClearHeaderCenter,
225
#patternClearHeaderLeft,
226
#patternClearHeaderRight,
227
#patternTopBarContentsOuter {
230
</verbatim></blockquote>
232
*Using style sheets:* %BR%
233
See PatternSkinCssCookbookNoTopBar
237
---+++ I want to hide the side bar
239
*Using templates:* %BR%
240
Omit =%<nop>TMPL:INCLUDE{"viewsidebar"}%= to hide the side bar, or in a custom template clear it using
241
<blockquote><verbatim>
242
%TMPL:DEF{"sidebar"}%%TMPL:END%
243
</verbatim></blockquote>
245
*Using style sheets:* %BR%
246
See PatternSkinCssCookbookNoLeftBar
251
---+++ I want to hide the edit buttons from certain users
253
It may defy the wiki-ness of your Foswiki 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.
255
Using either a template or a topic template, 'empty' =top:toolbarbuttons= and =topicaction= by writing:
257
%<nop>TMPL:INCLUDE{"view"}%
258
%<nop>TMPL:DEF{"top:toolbarbuttons"}%%TMPL:END%
259
%<nop>TMPL:DEF{"topicaction"}%%TMPL:END%
262
In the user page of %USERSWEB%.WikiGuest, set the cover to
264
* <nop>Set COVER = customer
267
By default this topic is editable only by Wiki admins.
269
---+++ I want to remove the History button from the bottom
271
All action links and buttons are defined in =viewtopicactionbuttons.tmpl=. The bottom history link is defined in DEF =action_revisions=
272
<blockquote><verbatim>
273
%TMPL:DEF{"topicactionbuttons"}%
274
%TMPL:P{"action_activatable_edit_or_create"}%
275
%TMPL:P{"action_activatable_attach"}%
276
%TMPL:P{"action_printable"}%
277
%TMPL:P{"action_revisions"}%
278
%TMPL:P{"action_backlinks_simple"}%
279
%TMPL:P{"action_raw_or_view"}%
280
%TMPL:P{"action_activatable_raw_edit"}%
281
%TMPL:P{"activatable_more"}%
283
</verbatim></blockquote>
285
To hide that link, In a custom skin view template =view.myskin.tmpl= empty =action_revisions= by replacing it with an empty string:
286
<blockquote><verbatim>
287
%TMPL:INCLUDE{"view"}%
288
%TMPL:DEF{"action_revisions"}%%TMPL:END%
289
</verbatim></blockquote>
292
---+++ I want to put the bottom links as buttons at the top
294
The default definition in =view.pattern.tmpl= is:
296
%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"activatable_edit_or_create"}%%TMPL:P{"activatable_attach"}%%TMPL:END%
299
Create a new skin by creating a file =view.myskin.tmpl= in the =templates= directory. Write in it:
301
<blockquote><verbatim>
302
%TMPL:INCLUDE{"view"}%
303
%TMPL:DEF{"top:toolbarbuttons"}%%TMPL:P{"history_history_link"}%%TMPL:END%
304
</verbatim></blockquote>
306
View any topic with =?skin=myskin,pattern=, or set the =SKIN= preference to =myskin,pattern=.
308
This will remove the Edit and Attach buttons, and place a History button at the top.
310
You will probably not just want to have the History button there. Other button include names are:
311
<blockquote><verbatim>
316
activatable_edit_or_create
318
activatable_printable
325
</verbatim></blockquote>
328
---++ Other page parts
330
---+++ I want to insert text outside of the topic content
332
!PatternSkin has 2 'buckets' to write additional content to: =contentheader= and =contentfooter=, both defined in =view.pattern.tmpl=. These containers can contain text or html and are placed directly before and after the topic text.
334
Both modules are wrapped in CSS containers:
335
* =contentheader= - wrapped in =div= of class =foswikiContentHeader=
336
* =contentfooter= - wrapped in =div= of class =foswikiContentFooter=
338
To put contents *before* the main text, use the custom skin approach as described above.%BR%
339
So our custom template contains:
340
<blockquote><verbatim>
341
%TMPL:INCLUDE{"view"}%
342
%TMPL:DEF{"contentheader"}%This is the text before%TMPL:END%
343
</verbatim></blockquote>
345
Use the same procedure for contents to be put *after* the topic text:
346
<blockquote><verbatim>
347
%TMPL:INCLUDE{"view"}%
348
%TMPL:DEF{"contentfooter"}%This is the text after%TMPL:END%
349
</verbatim></blockquote>
351
---+++ I want to place the form at the top
353
Pattern skin has 2 buckets for the form: =formtop= (form at the top) and =formbottom= (form at the bottom). The default definition is:
357
%TMPL:DEF{"formtop"}%%TMPL:END%
358
%TMPL:DEF{"formbottom"}%%TMPL:P{"form"}%%TMPL:END%
362
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{"formtop"}%%TMPL:P{"form"}%%TMPL:END%
368
%TMPL:DEF{"formbottom"}%%TMPL:END%