Wiki source code of Panel Content Macros and Variables
Last modified by Eleni Cojocariu on 2026/08/28 09:53
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
![]() |
2.1 | 1 | The "Content" property of a Panel is rendered like any wiki page, with these Velocity macros and variables available on top of the usual ones. The macros come from ##macros.vm## in the web templates module; wrap the body of every Panel in a header and a footer so it is given the markup, the title and the landmark role the skin expects. |
| 2 | |||
| 3 | == Macros == | ||
| 4 | |||
| 5 | |=Macro|=Parameters|=Effect | ||
| 6 | |##panelheader##|##$title##, ##$isLarge##, ##$isHeaderHidden##, ##$isNavigation##|Opens the Panel with ##$title## as its heading and as the Panel's accessible name, and with the ##complementary## landmark role. The three flags default to false, and the four macros below are the combinations of them worth naming. | ||
| 7 | |##largepanelheader##|##$title##|As above, plus the ##large## CSS class for a Panel meant to fill a wide column. | ||
| 8 | |##panelhiddenheader##|##$title##|As ##panelheader##, with the heading hidden while still being announced to assistive technology. | ||
| 9 | |##navigationPanelHeader##|##$title##|As ##panelheader##, but with the ##navigation## landmark role, for a Panel whose content is a set of links to navigate by. | ||
| 10 | |##largeNavigationPanelHeader##|##$title##|The ##large## and ##navigation## combination. | ||
| 11 | |##panelfooter##|none|Closes whichever header was opened. Every header needs exactly one. | ||
| 12 | |||
| 13 | Writing the header and footer by hand instead of calling the macros costs the Panel its landmark role, so a screen-reader user loses the ability to jump to it: | ||
| 14 | |||
| 15 | {{code language="velocity"}} | ||
| 16 | #navigationPanelHeader('Quick links') | ||
| 17 | |||
| 18 | * [[Sandbox>>Sandbox.WebHome]] | ||
| 19 | * [[Blog>>Blog.WebHome]] | ||
| 20 | |||
| 21 | #panelfooter() | ||
| 22 | {{/code}} | ||
| 23 | |||
| 24 | == Variables == | ||
| 25 | |||
| 26 | |=Variable|=Type|=Holds | ||
| 27 | |##$paneldoc##|Document|The Panel's own document. Use it to reach the Panel's attachments or xobjects. | ||
| 28 | |##$doc##|Document|The page the Panel is being displayed on, which is what a Panel tests to decide whether to output anything. | ||
| 29 | |##$xwikiPanelWidth##|String|The width configured for the column the Panel is in: ##Small##, ##Medium## or ##Large##. It is reset to ##Medium## outside a column, so a Panel rendered through the Display Panel Layout Macro reads that value. | ||
| 30 | |||
| 31 | A Panel that adapts to the column it sits in branches on the width rather than measuring anything: | ||
| 32 | |||
| 33 | {{code language="velocity"}} | ||
| 34 | #panelheader('Members') | ||
| 35 | #if ($xwikiPanelWidth == 'Small') | ||
| 36 | ## avatars only | ||
| 37 | #else | ||
| 38 | ## avatars and names | ||
| 39 | #end | ||
| 40 | #panelfooter() | ||
| 41 | {{/code}} |
