Wiki source code of Create a Change Displayer
Last modified by Vincent Massol on 2026/09/03 22:05
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | A displayer is one wiki page rendering a list of changes; the four bundled ones are described in [[Change Displayers>>doc:documentation.extensions.user.release-notes.change-displayers.WebHome]]. | ||
| 2 | |||
| 3 | 1. Create a page named ##ChangeDisplayer<Name>## in the ##ReleaseNotes.Code.Change## space, for example ##ChangeDisplayerCards##.((( | ||
| 4 | {{image reference="custom-displayer-page.png" size="extra" alt="The new displayer page in place under the Change space of the application"/}} | ||
| 5 | ))) | ||
| 6 | 1. Include the shared Velocity macros and loop over the ##$changeItems## binding, reading each change from its ##ChangeClass## object, escaping its title and displaying its summary through the change document.((( | ||
| 7 | {{code language="velocity"}} | ||
| 8 | {{include reference="ReleaseNotes.Code.Change.ChangeDisplayerVelocityMacros"/}} | ||
| 9 | |||
| 10 | {{velocity}} | ||
| 11 | #foreach ($item in $changeItems) | ||
| 12 | #set ($changeDoc = $xwiki.getDocument($item)) | ||
| 13 | #set ($changeObject = $changeDoc.getObject('ReleaseNotes.Code.Change.ChangeClass')) | ||
| 14 | #set ($title = $services.rendering.escape("$!changeObject.getValue('title')", 'xwiki/2.1')) | ||
| 15 | #generateDisplayEditLink($displayEditLink, $changeDoc) | ||
| 16 | {{info}} | ||
| 17 | **$title**${displayEditLinkMarkup} | ||
| 18 | |||
| 19 | $changeDoc.display('summary', 'view', $changeObject) | ||
| 20 | {{/info}} | ||
| 21 | |||
| 22 | #end | ||
| 23 | {{/velocity}} | ||
| 24 | {{/code}} | ||
| 25 | ))) | ||
| 26 | 1. Pass the lowercase name to the ##displayer## parameter, here ##displayer="cards"##, from a report or from the ##displayChanges## macro. | ||
| 27 | 1. The changes are rendered by your displayer.((( | ||
| 28 | {{image reference="custom-displayer-result.png" size="large" alt="Changes rendered as information boxes by the custom Cards displayer"/}} | ||
| 29 | ))) |