Wiki source code of How to display a panel only on a particular page??
Version 8.1 by Buzila Vlad on 2016/06/08
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
5.2 | 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: |
![]() |
1.1 | 2 | |
![]() |
5.3 | 3 | == 1. Create or edit the panel == |
![]() |
1.1 | 4 | |
![]() |
5.2 | 5 | Make sure that the panel's code resembles the following: |
6 | |||
![]() |
5.3 | 7 | {{code language="velocity"}} |
![]() |
1.1 | 8 | {{velocity}} |
9 | #if ($doc.fullName == "Main.WebHome") | ||
![]() |
5.5 | 10 | #panelheader($services.localization.render('xe.panels.quicklinks')) |
![]() |
5.3 | 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() | ||
![]() |
1.1 | 17 | #end |
18 | {{/velocity}} | ||
19 | {{/code}} | ||
20 | |||
![]() |
5.2 | 21 | The pages ##Blog.News## and ##Blog.Iasi## (from this example) should already exist, otherwise the links will point to non-existing pages. |
![]() |
1.1 | 22 | |
![]() |
5.2 | 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: |
![]() |
1.1 | 24 | |
![]() |
5.2 | 25 | {{code}} |
26 | #if ($doc.fullName == "Main.WebHome") | ||
27 | ... panel content here ... | ||
28 | #end | ||
29 | {{/code}} | ||
![]() |
1.1 | 30 | |
![]() |
5.6 | 31 | The final panel creation should resemble the following: |
![]() |
5.8 | 32 | |
![]() |
1.1 | 33 | [[image:newpanel.png]] |
34 | |||
![]() |
5.3 | 35 | == 2. Register the panel == |
![]() |
1.1 | 36 | |
![]() |
5.2 | 37 | Add the panel to the desired column (e.g. to the right column) from ##Administration > Page Elements > Panels displayed on right column##: |
38 | |||
![]() |
1.1 | 39 | [[image:addpaneltocolumn.png]] |
40 | |||
![]() |
5.4 | 41 | == 3. Navigate to ##Main.WebHome## to see the panel displayed **only** on the homepage == |
![]() |
1.1 | 42 | |
43 | [[image:pageshownonmain.png]] | ||
44 | |||
![]() |
5.2 | 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. |