Wiki source code of How to display a panel only on a particular page??
Version 8.1 by Buzila Vlad on 2016/06/08
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | As a user which wants to display a panel (e.g. with some links) only on a particular page (e.g. on "Main.WebHome") you must follow the following: | ||
2 | |||
3 | == 1. Create or edit the panel == | ||
4 | |||
5 | Make sure that the panel's code resembles the following: | ||
6 | |||
7 | {{code language="velocity"}} | ||
8 | {{velocity}} | ||
9 | #if ($doc.fullName == "Main.WebHome") | ||
10 | #panelheader($services.localization.render('xe.panels.quicklinks')) | ||
11 | * [[News>>Blog.News]] | ||
12 | ** [[Iasi>>Blog.Iasi]] | ||
13 | #if ($xwiki.hasAdminRights()) | ||
14 | [[$services.localization.render('xe.panels.edit')>>path:${xwiki.getURL('Panels.newtwo', 'inline')}]] | ||
15 | #end | ||
16 | #panelfooter() | ||
17 | #end | ||
18 | {{/velocity}} | ||
19 | {{/code}} | ||
20 | |||
21 | The pages ##Blog.News## and ##Blog.Iasi## (from this example) should already exist, otherwise the links will point to non-existing pages. | ||
22 | |||
23 | The key to deciding if a panel should be displayed or not on a page is the following condition in the code which (in this case) decides that the panel should only be displayer on the homepage: | ||
24 | |||
25 | {{code}} | ||
26 | #if ($doc.fullName == "Main.WebHome") | ||
27 | ... panel content here ... | ||
28 | #end | ||
29 | {{/code}} | ||
30 | |||
31 | The final panel creation should resemble the following: | ||
32 | |||
33 | [[image:newpanel.png]] | ||
34 | |||
35 | == 2. Register the panel == | ||
36 | |||
37 | Add the panel to the desired column (e.g. to the right column) from ##Administration > Page Elements > Panels displayed on right column##: | ||
38 | |||
39 | [[image:addpaneltocolumn.png]] | ||
40 | |||
41 | == 3. Navigate to ##Main.WebHome## to see the panel displayed **only** on the homepage == | ||
42 | |||
43 | [[image:pageshownonmain.png]] | ||
44 | |||
45 | In the our example, we have used ##Main.WebHome## as the page where to display the panel but you can use any other page or pages from your wiki and you can make the rule as complex as you want. |