Pattern Skin Customization
Questions and answers on configuring page elements. For styling your TWiki, see Pattern Skin Css Cookbook.On this page:
First Read: How to modify PatternSkin templates
Everything you see on the common 'view' page is written by theview template. For pattern skin this file is /templates/view.pattern.tmpl.
We describe two approaches to override this template: - By creating a custom skin file in the
templatesdirectory - By creating a custom topic template
- If you want to change the appearance for a lot of pages or even site-wide, the template approach is the easiest.
- If you want to change the appearance of a single topic, or a set of topics, use a topic template.
The template approach
To change templates you will need shell access. If you don't have this read on below in The topic template approach. 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. ExampleLet'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.
The steps you would need: - Think up a name for your skin. Let us use
myskinfor now. - Create a new (empty) view template file in
/templatescalledview.myskin.tmpl. - In
view.myskin.tmplyou write:%TMPL:INCLUDE{"view"}% %TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"activatable_more"}%%TMPL:END% - For testing, view any topic and append to the topic name:
?cover=myskin. You should see an effect now. - To make the changes visible on all pages, go to Main.TWiki Preferences (to keep TWiki Preferences intact) and write:
Test by appending* Set COVER = myskinor write* Set SKIN = myskin,pattern
?cover=myskin to the url.
The topic template approach (using VIEW_TEMPLATE)
Template overrides can be written in a topic, a so-called topic template. Topic template names end withTemplate, for instance BlogPostViewTemplate.
Call this template by setting VIEW_TEMPLATE:
* Set VIEW_TEMPLATE = BlogPostView
- Note that you don't use the
Templateextension now - You can make this setting hidden by writing this in the Settings screen: go to More and then Topic Settings
- On topic creation you can set the topic template by passing
templatetopic:<input type="hidden" name="templatetopic" value="BlogPostViewTemplate" />
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"topicactionbuttons"}%%TMPL:P{"activatable_more"}%%TMPL:END%
You can also test this by appending ?template=PersonalInfoView to the url.
Reference: pattern skin template INCLUDE tree
view
page
constants
javascript
styles
stylesdynamic
body
viewtopbar
%SYSTEMWEB%.WebTopBar
viewtoolbar
viewleftbar
%WEB%.WebLeftBar
viewtopicactionbuttons
viewbottombar
%SYSTEMWEB%.WebBottomBar
Logo
How can I change the web logo?
By default the logo at the top left of each web points to the image with namelogo.gif that is attached to each web's Web Preferences. The default variables that cause this behavior are defined in TWiki Preferences. Redefine your custom variables in Main.TWiki Preferences (to keep TWiki Preferences intact):
* Set WEBLOGONAME = logo.gif
* Set WEBLOGOIMG = %PUBURLPATH%/%BASEWEB%/%WEBPREFSTOPIC%/%WEBLOGONAME%
* Set WEBLOGOURL = %SCRIPTURLPATH{"view"}%/%BASEWEB%/%HOMETOPIC%
* Set WEBLOGOALT = Home
There are 2 ways to change the logo in a web:
Using logo.gif:
Using a new filename:
- Create a new image named
logo.gifand attach it to the web's Web Preferences topic. Pattern Skin's stylesheet assumes the logo is 40px high. More about that later.- You can also upload the image with FTP to
/pub/YourWeb/WebPreferences/.- Copy the above instructions ("Redefine your custom variables") and insert your logo name.
- Attach whatever image and attach it to the web's Web Preferences topic. Then add to the Web Preferences (under Custom web preferences):
* Set WEBLOGONAME = your-logo-name.gif-or-png
- Copy the above instructions ("Redefine your custom variables") and insert your logo name.
How do I set a site-wide logo?
There is a bunch of site-wide logo variables in Main.TWiki Preferences:WIKILOGOIMG, WIKILOGOURL and WIKILOGOALT.
To change only the web logo image to site-wide, in Main.TWiki Preferences set:
* Set WEBLOGOIMG = %WIKILOGOIMG%
My logo does not fit the top bar
See I want to change the height of the top barI want to change the white space above and below the logo
Change the table style in topic Web Top Bar. The default top padding is 11px.Top bar
The search box won't find topics in other webs
In Web Top Bar you can find the line:<input type="hidden" name="web" value="%BASEWEB%" />To search all webs, write:
To search a couple of webs, for instance the webs Main and TWiki, write:<input type="hidden" name="web" value="all" />
See also: Search variable<input type="hidden" name="web" value="Main,TWiki" />
I want to change the height of the top bar
The top bar is 64 pixels high by default. Using templates:Using either a template or a topic template, copy this definition in your custom template:
%TMPL:DEF{"topbardimensions"}%
#patternTopBar,
#patternClearHeaderCenter,
#patternClearHeaderLeft,
#patternClearHeaderRight,
#patternTopBarContentsOuter {
height:64px; /* top bar height; make room for header columns */
overflow:hidden;
}
%TMPL:END%
And change the number from 64px to a different value.
Using style sheets:
Create a new stylesheet with above definition in it, attach it to a topic and point USERLAYOUTURL to that topic attachment. See Pattern Skin Css Cookbook about creating custom styles.
I want to set or change the top background image
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 variableWEBHEADERART, defined in TWiki Preferences.
Redefine your custom variables in Main.TWiki Preferences (to keep TWiki Preferences intact):
You can also set* Set WEBHEADERART = %PUBURLPATH%/%SYSTEMWEB%/PatternSkin/TWiki_header.gif * Set WEBHEADERBGCOLOR = somehexcolor (no quotes, for example: #ffffff)
WEBHEADERART per web, by defining the variable in the Web's WebPreferences.
I want to have the web color in the top bar
RedefineWEBHEADERBGCOLOR in Main.TWiki Preferences (to keep TWiki Preferences intact):
* Set WEBHEADERBGCOLOR = %WEBBGCOLOR%
I want to remove the Jump and Search boxes from the top bar
If you have localization enabled, you will also see a language dropdown box at the far right. You can remove these items from Web Top Bar.I want to hide the top bar
Using templates: The view template is populated with page elements using template inclusions:
%TMPL:INCLUDE{"page"}%
%TMPL:INCLUDE{"viewtopbar"}%
%TMPL:INCLUDE{"viewtoolbar"}%
%TMPL:INCLUDE{"viewleftbar"}%
%TMPL:INCLUDE{"viewrightbar"}%
%TMPL:INCLUDE{"viewtopicactionbuttons"}%
%TMPL:INCLUDE{"viewbottombar"}%
Each included template draws a part of the screen.Omit
%TMPL:INCLUDE{"viewtopbar"}% to hide the top bar.
Another approach is to clear the contents of module topbar. Using either a template or a topic template, write in your custom template:
Using style sheets:%TMPL:INCLUDE{"view"}% %TMPL:INCLUDE{"topbar"}%%TMPL:END%and add:%TMPL:DEF{"topbardimensions"}%#patternTopBar, #patternClearHeaderCenter, #patternClearHeaderLeft, #patternClearHeaderRight, #patternTopBarContentsOuter { height:0px; }%TMPL:END%
See Pattern Skin Css Cookbook No Top Bar
Left bar
I want to hide the left bar
Using templates:Omit
%TMPL:INCLUDE{"viewleftbar"}% to hide the left bar, or in a custom template clear it using
%TMPL:DEF{"viewleftbar"}%%TMPL:END%
Using style sheets: See Pattern Skin Css Cookbook No Left Bar
I want to make the left bar wider
Using templates:The left bar is 12 em wide by default. Using templates:
Using either a template or a topic template, copy this definition in your custom template:
%TMPL:DEF{"leftbardimensions"}%#patternOuter {
margin-left:12em;
}
#patternLeftBar {
width:12em;
margin-left:-12em;
}%TMPL:END%
And change the number from 12em to a different value (3 occurrences).
Other page parts
I want to hide the edit buttons from certain users
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. Using either a template or a topic template, 'empty'topicaction and toolbar by writing:
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"topicaction"}%%TMPL:END%
%TMPL:DEF{"toolbar"}%%TMPL:END%
In the user page of TWiki Guest, set the cover to
By default this topic is editable only by TWiki admins.* Set COVER = customer
I want to remove the History button from the bottom
All action buttons are defined inviewtopicactionbuttons.pattern.tmpl. The history buttons or in module revisions:
%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"}% < HERE
%TMPL:P{"activatable_more"}%%TMPL:END%
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. Using either a template or a topic template, to remove the history buttons write in your custom template:
%TMPL:INCLUDE{"view"}%
%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{"activatable_more"}%%TMPL:END%
Remove all newlines if you copy-paste above text.
I want to insert text outside of the topic content
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.
Both modules are wrapped in CSS containers: -
beforetextcontents- wrapped indivof classtwikiBeforeText -
aftertextcontents- wrapped indivof classtwikiAfterText
So our custom template contains:
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"beforetextcontents"}%This is the text before%TMPL:END%
Use the same procedure for contents to be put after the topic text:
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"aftertextcontents"}%This is the text after%TMPL:END%
I want to place the form at the top
Pattern skin has 2 buckets for the form:formattop (form-at-the-top) and formatbottom (form-at-the-bottom):
%TMPL:DEF{"formattop"}%%TMPL:END%
%TMPL:DEF{"formatbottom"}%%TMPL:P{"form"}%%TMPL:END%
You simply swap the bucket contents. Using either a template or a topic template, write in your custom template:
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"formattop"}%%TMPL:P{"form"}%%TMPL:END%
%TMPL:DEF{"formatbottom"}%%TMPL:END%
I only want to show the WYSIWYG button on explicit pages
In Main.TWiki Preferences, setCOMPOSER to a blank value:
In the topic, set the* Set COMPOSER =
COMPOSER variable to kupu:
* Set COMPOSER = kupu
| Topic PatternSkinCustomization . { Edit | Attach | Backlinks: Web All webs | Printable | History: r7 < r6 < r5 < r4 < r3 More } |