Show last authors
1 {{velocity}}
2 $xwiki.ssx.use($doc.fullName)
3 {{/velocity}}
4 (% class="floatinginfobox" %)(((
5 **Contents**
6
7 {{toc depth="3" start="2"/}}
8 )))
9 ==XWiki Skins==
10
11 {{id name="s4" /}}==How to create a new Skin==
12 {{warning}}
13 To create a new Skin, you must have access to the server side of the XWiki Enterprise instance.
14 {{/warning}}
15 To create a new Skin, you have to create a new direcory inside the (% class="sectionblockcodecolored directory"%)webapps/xwiki/skins(%%) folder and then add Velocity templates, {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} stylesheets, Javascript files and images inside it. For example, if you want to remove the logo from the header of the pages, follow these steps:
16 1. inside the (% class="sectionblockcodecolored directory"%)webapps/xwiki/skins(%%) folder, create a folder named (% class="sectionblockcodecolored"%)myskin(%%)
17 1. change the Skin at (% class="sectionblockcodecolored"%)instance(%%) level and set it as (% class="sectionblockcodecolored"%)myskin(%%) ( see the section [[C-2>>AdminGuide.Skins#3c2]] for more informations about how to change the Skin )
18 1. open any page in view mode and you will notice that (% class="sectionblockcodecolored"%)myskin(%%) layout is the same as the (% class="sectionblockcodecolored"%)albatross(%%) layout ( this happens because on having no Skin set as the Skin, the default Skin is considered to be (% class="sectionblockcodecolored"%)albatross(%%) )
19 1. change the (% class="sectionblockcodecolored"%)global(%%) template:
20 1*. copy the (% class="sectionblockcodecolored directory"%)webapps/templates/global.vm(%%) template and paste it inside the (% class="sectionblockcodecolored"%)myskin(%%) folder
21 1*. to remove the logo, modify the (% class="sectionblockcodecolored"%)global(%%) template under the new Skin and delete the line:(% class="overflow-auto" %)((({{code language="xml"}}<img src="$!logourl" alt="XWiki" width="200" height="70"/>{{/code}} )))
22 1. save the template
23
24 Open any page in view mode and you will notice that the XWiki logo is not displayed anymore.
25 Congratulations! You have created a new minimal XWiki Skin.
26
27 {{id name="s5" /}}==How to override a Skin==
28 {{warning}}
29 To change the Skin, the user must have administrating rights. In the case that you have these rights, make sure that you switch to the Advanced mode in your profile, to enable the advanced options on the top main menu.
30 {{/warning}}
31 An alternative for creating a new Skin is the possibility to override an existing Skin. The advantage of overriding an existing Skin is the fact that you don't need access to the server filesystem in order to modify the files used by the current Skin.
32 To override a Skin, you have to use the same document that is used to store the Skin.
33 {{id name="5a" /}}===A. Creating a Skin document===
34 {{warning}}You need to have the **advance edition mode** activated to access the object editor. Please refer to [[platform:Features.PageEditing]] for more information.{{/warning}}
35 To create a new Skin document, follow these steps:
36 |(% style="width:60%;color:#222"%)(((
37 1. create a new page - if there is the option (% class="sectionblockcodecolored"%)CREATE -> PAGE(%%) on the main menu, use it to create a page, or, if there is no such option, add the (% class="sectionblockcodecolored"%)New Page(%%) panel on the interface by following these steps:
38 1*. go to (% class="sectionblockcodecolored"%)Administration -> Panel Wizard(%%)
39 1*. select the (% class="sectionblockcodecolored"%)Tools(%%) category
40 1*. add the (% class="sectionblockcodecolored"%)New Page(%%) panel on the interface by using drag&drop
41 1*. click on (% class="sectionblockcodecolored"%)Save the new layout(%%) to save your changes
42 1*. open any page in view mode and
43 1*. use the (% class="sectionblockcodecolored"%)New Page(%%) panel to create a page
44 1. edit the document's objects ( if you are in (% class="sectionblockcodecolored"%)edit(%%) mode, use the right panel and choose the (% class="sectionblockcodecolored"%)Objects(%%) editor, or, if you are in (% class="sectionblockcodecolored"%)view(%%) mode, use the top-left menu: (% class="sectionblockcodecolored"%)EDIT{{html}}&nbsp;->&nbsp;{{/html}}OBJECTS(%%))
45 1. add an object of type (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) to the document (use the **ADD OBJECT** panel from the right and select the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) class, then click on (% class="sectionblockcodecolored"%)ADD OBJECT FROM THIS CLASS(%%))
46 1. save the document
47 )))|((([[[[image:4.png||width="100%" style="border:3px solid #ddd;"]]>>attach:4.png]])))
48
49 {{id name="5b" /}}===B. Working with the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) class===
50 The base element in overriding a Skin is the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) class ( http://localhost:8080/xwiki/bin/view/XWiki/XWikiSkins ). In order to modify the templates or the files used by a Skin, you have to work with the properties of this class.
51 By default, the Skin class contains a set of properties that allows you to override some of the templates and files used by the Skin, and it also allows you to set the name of the logo displayed in the header of the interface.
52 To override other templates or files, you have to add new properties to the Skin class. For example, if you want to override (% class="sectionblockcodecolored"%)myfile.vm(%%) ( or myfile.css, or myfile.js ), follow these steps:
53 |(% style="width:60%;color:#222"%)(((
54 1. go to the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) document
55 1. click on the (% class="sectionblockcodecolored"%)add or modify the class properties(%%) link
56 ( or follow this link: http://localhost:8080/xwiki/bin/edit/XWiki/XWikiSkins?editor=class )
57 1. from the **ADD PROPERTY** panel in the right, set the name of the property as being (% class="sectionblockcodecolored"%)myfile.vm(%%), choose the (% class="sectionblockcodecolored"%)TextArea(%%) type, and click on (% class="sectionblockcodecolored"%)Add(%%)
58 1. save the document
59 )))|((([[[[image:5.png||width="100%" style="border:3px solid #ddd;"]]>>attach:5.png]])))
60
61 {{id name="5c" /}}===C. Using a Skin document===
62 To use a Skin document, follow these steps:
63 1. go to the (% class="sectionblockcodecolored"%)Skin(%%) property from inside the (% class="sectionblockcodecolored"%)Administration(%%) interface
64 1. set the value of the property as being the full name of the Skin document
65 1. save the preferences
66
67 {{id name="5d" /}}===D. Overriding the Skin components===
68 Let's add a "HELLO," before the username on the top right menu, not by modifying the (% class="sectionblockcodecolored"%)global.vm(%%) template on the server, but overriding it inside the Skin document. Follow these steps:
69 |(% style="width:60%;color:#222;overflow-x:auto;"%)(((
70 1. add a (% class="sectionblockcodecolored"%)TextArea(%%) property named (% class="sectionblockcodecolored"%)global.vm(%%) to the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) class
71 1. edit the Skin document's objects ( use the top-left menu: (% class="sectionblockcodecolored"%)EDIT -> OBJECTS(%%) ) and open the properties of the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) object
72 1. copy the original content of the (% class="sectionblockcodecolored"%)global.vm(%%) template and paste it in the property field named (% class="sectionblockcodecolored"%)global.vm(%%); if you don't have access to the server filesystem, open the template by following one of these links:
73 1*. http://localhost:8080/xwiki/skins/mybaseskin/global.vm ( where mybaseskin is the current Skin used in the Skin document ), or
74 1*. if the previous link is not valid, go to http://localhost:8080/xwiki/templates/global.vm
75 1. replace the following code: (% style="overflow-x:auto;" %)((({{code language="xml"}}<a class="glink"
76 href="$!xwiki.getURL($context.user, 'view')"
77 id="headeruser">
78 $!xwiki.getUserName($context.user, false)
79 </a>{{/code}})))with (% style="overflow-x:auto;" %)((({{code language="xml"}}<a class="glink"
80 href="$!xwiki.getURL($context.user, 'view')"
81 id="headeruser">
82 HELLO,
83 $!xwiki.getUserName($context.user, false)
84 </a>{{/code}})))
85 1. save the document
86 )))|((([[[[image:6.png||width="100%" style="border:3px solid #ddd;"]]>>attach:6.png]])))
87
88 Now, open any document in view mode and you will notice the nice "HELLO," before your username.
89 Follow the same process in order to override (% class="sectionblockcodecolored"%)Javascript(%%) and (% class="sectionblockcodecolored"%){{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}}(%%) files ( http://localhost:8080/xwiki/skins/colibri/myfile.css ).
90
91 {{id name="5e" /}}===E. Adding new components to the Skin===
92 If you want to add new files to the skin, like (% class="sectionblockcodecolored"%){{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} (%%) or (% class="sectionblockcodecolored"%)Javascript(%%) files, you have two options:
93 * attach the files to the Skin document and reffer them by their URL, or
94 * add new properties to the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) object from inside the Skin document, and refer them by their name
95
96 For example, if you want to add a new {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} file to the Skin, named (% class="sectionblockcodecolored"%)mynewfile.css(%%), follow one of these set of steps:
97 |(% style="width:60%;color:#222"%)(((
98 1. attach the {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} file to the Skin document
99 1. override the stylesheets.vm template ( check the section [[D>>#5d]] to learn how to override a Skin component ), and add the reference to your file in the template:(% class="overflow-auto" %)((({{code language="xml"}}<link rel="stylesheet"
100 type="text/css"
101 href="$xwiki.getSkinFile('mynewfile.css')"
102 />{{/code}})))
103 1. save the document
104 )))|((([[[[image:7.png||width="100%" style="border:3px solid #ddd;"]]>>attach:7.png]])))
105
106 OR
107 |(% style="width:60%;color:#222"%)(((
108 1. add a new property to the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%), name it (% class="sectionblockcodecolored"%)mynewfile.css(%%) ( check the section [[B>>#5b]] for more information about how to work with this class ), edit the Skin document's objects ( use the top-left menu: (% class="sectionblockcodecolored"%)EDIT -> OBJECTS(%%) ), and paste the {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} code into the (% class="sectionblockcodecolored"%)mynewfile.css(%%) field
109 1. override the (% class="sectionblockcodecolored"%)style.css(%%) component ( see the section [[D>>#5d]] for more information about how to override a Skin compoment ) and add the following line to the content of the (% class="sectionblockcodecolored"%)style.css(%%) property:(% class="overflow-auto" %)((({{code language="css"}}@import "mynewfile.css";{{/code}} ))) the important thing is to add a reference to the new component from a existing one; you must know most of the components content, so that you will take the best decision about which existing component will contain a reference to the new one
110 1. save the document
111 )))|((([[[[image:8.png||width="100%" style="border:3px solid #ddd;"]]>>attach:8.png]])))
112
113 Open any document in view mode and you will notice that the stylesheet is now applied.
114
115 {{id name="5f" /}}===F. Using (% class="sectionblockcodecolored"%)images(%%) in a Skin document==={{id name="5f1" /}}====1. Changing the (% class="sectionblockcodecolored"%)logo(%%)====
116 For example, if you want to add an image named (% class="sectionblockcodecolored"%)myimage.jpg(%%) as being the logo for the current Skin, follow these steps:
117 1. attach the image to the Skin document
118 1. edit the document's objects ( use the top-left menu: (% class="sectionblockcodecolored"%)EDIT -> OBJECTS(%%) )
119 1. use the (% class="sectionblockcodecolored"%)XWiki.XWikiSkins(%%) object and set the (% class="sectionblockcodecolored"%)Logo(%%) property as being the name of the attached image: (% class="sectionblockcodecolored"%)myimage.jpg(%%)
120 1. save the document
121
122 Open any page in view mode and you will notice that the logo is now changed.
123
124 {{id name="5f2" /}}
125 ====2. Adding images to the Skin interface====
126 To add images to the interface, attach them to the Skin document and use them in the {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} code. For example, if you want to use (% class="sectionblockcodecolored"%)myimage.jpg(%%) as background image for the pages inside your XWiki Enterprise instance, follow these steps:
127 1. attach the image to the Skin document
128 1. choose one of these actions:
129 1*. add a new {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} component to the Skin, name it (% class="sectionblockcodecolored"%)pagebackground.css(%%) and add a reference to it from the (% class="sectionblockcodecolored"%)style.css(%%) component ( see the section [[E>>#5e]] for more information about how to add new components to the Skin )
130 1*. override the (% class="sectionblockcodecolored"%)mybaseskin.css(%%) component ( where mybaseskin is the name of the current Skin - for example: (% class="sectionblockcodecolored"%)albatross.css(%%), (% class="sectionblockcodecolored"%)toucan.css(%%) or (% class="sectionblockcodecolored"%)colibri.css(%%) )
131 1. paste the following code inside the {{html}}<acronym title="Cascading Style Sheets">CSS</acronym>{{/html}} component:(% class="codeblock overflow-auto addcode" %)((({{code language="css"}}body{
132 background-image: url($xwiki.getSkinFile("myimage.jpg"));
133 }{{/code}} )))
134
135 Open any page in view mode and you will notice that the the background of the page contains your image.
136 Have fun taking advantage of the power of XWiki Skins!
137
138 ==More about XWiki Skins==
139 In order to find more about XWiki Skins, check the [[Skins Tutorial>>AdminGuide.Skins]] from inside the Admin Guide and the [[Skins Tutorial>>Features.Skins]] from inside the User Guide
140
141 ==Further reading==
142 * the [[XWiki Data Model>>http://platform.xwiki.org/xwiki/bin/view/DevGuide/DataModel]]
143 * using the [[Skin Editor Application>>http://code.xwiki.org/xwiki/bin/view/Applications/SkinEditorApplication]]
144 * [[edit only one object>>http://dev.xwiki.org/xwiki/bin/view/Drafts/EditOneObject]]

Get Connected