0 Votes

Wiki source code of MyWiki

Version 9.1 by Ryan C on 2025/04/28 06:25

Show last authors
1 = XWiki Macros Reference Guide {{id name="xwiki-macros-reference-guide" /}}=
2
3 Macros in XWiki are reusable pieces of functionality that can be integrated inside pages. They allow you to insert dynamic content or apply special formatting using a simple syntax. Below is a list of available macros (excluding deprecated or internal macros) along with their descriptions and usage examples.
4
5 == Box Macro {{id name="box-macro" /}}==
6
7 The **Box** macro draws a box around the content inside it​:contentReference[oaicite:0]{index=0}. This is useful for highlighting important information or grouping related content in a styled panel.
8
9 **Example:** A simple box with a custom title
10
11 **Note:** This is a sample box message.
12 **Source:**
13
14
15 {{code}}
16 {{box title="Note"}} This is a sample box message. {{/box}}
17 {{/code}}
18
19 == Info Macro {{id name="info-macro" /}}==
20
21 The **Info** macro displays an informational message in a styled box format​:contentReference[oaicite:1]{index=1}. It is typically rendered with a distinctive color (often blue) to denote general information. This macro inherits all parameters from the Box macro​:contentReference[oaicite:2]{index=2} (such as the optional {{code}}title{{/code}}).
22
23 **Example:** An info message box
24
25 This is an informational message.
26 **Source:**
27
28
29 {{code}}
30 {{info}}This is an informational message{{/info}}
31 {{/code}}
32
33 **Example (with title):** An info message with a title
34
35 **FYI:** This is an informational message.
36 **Source:**
37
38
39 {{code}}
40 {{info title="FYI"}} This is an informational message. {{/info}}
41 {{/code}}
42
43 == Warning Macro {{id name="warning-macro" /}}==
44
45 The **Warning** macro highlights a warning message in a styled box (usually with a yellow/orange background)​:contentReference[oaicite:3]{index=3}. It inherits the same optional parameters as the Box macro (like {{code}}title{{/code}}).
46
47 **Example:** A warning message box
48
49 This is a warning message.
50 **Source:**
51
52
53 {{code}}
54 {{warning}}This is a warning message{{/warning}}
55 {{/code}}
56
57 == Success Macro {{id name="success-macro" /}}==
58
59 The **Success** macro displays a success message in a styled box (often green) to indicate a successful action or outcome​:contentReference[oaicite:4]{index=4}. Like other message macros, it supports the same parameters as the Box macro.
60
61 **Example:** A success message box
62
63 This is a success message.
64 **Source:**
65
66
67 {{code}}
68 {{success}}This is a success message{{/success}}
69 {{/code}}
70
71 == Error Macro {{id name="error-macro" /}}==
72
73 The **Error** macro displays an error or alert message in a styled box (commonly red)​:contentReference[oaicite:5]{index=5}. It is used to draw attention to critical issues or errors. Like the info and warning macros, it also inherits Box macro parameters.
74
75 **Example:** An error message box
76
77 This is an error message.
78 **Source:**
79
80
81 {{code}}
82 {{error}}This is an error message{{/error}}
83 {{/code}}
84
85 == Chart Macro {{id name="chart-macro" /}}==
86
87 The **Chart** macro generates a graphical chart (pie, bar, line, etc.) from provided data sources​:contentReference[oaicite:6]{index=6}. It can take data from an inline table or from an external source (another page, attachment, etc.), and supports various chart types through the {{code}}type{{/code}} parameter (e.g., pie, bar, line).
88
89 **Example:** An inline pie chart
90
91 (This chart would show the distribution of three categories A, B, and C in a pie chart.)
92
93 **Source:**
94
95
96 {{code}}
97 {{chart type="pie" source="inline" params="range:B2-B4;series:columns;" width="400" height="300"}} |=Category|=Value| |A|10| |B|20| |C|30| {{/chart}}
98 {{/code}}
99
100 In the above example, a pie chart is created using an inline table as the data source. The table defines one category column and one value column, and the {{code}}series:columns{{/code}} parameter instructs the macro to treat each column of values as a data series​:contentReference[oaicite:7]{index=7}​:contentReference[oaicite:8]{index=8}.
101
102 **Example (multi-series bar chart):** An inline bar chart comparing two data series
103
104 (This chart would display a bar chart with categories Q1–Q3 on the X-axis, and two series "Product X" and "Product Y" as different colored bars.)
105
106 **Source:**
107
108
109 {{code}}
110 {{chart type="bar" source="inline" params="range:B2-C4;series:columns;" width="500" height="300"}} |=Quarter|=Product X|=Product Y| |Q1|20|15| |Q2|30|25| |Q3|25|30| {{/chart}}
111 {{/code}}
112
113 Here we specify a bar chart with two series. The table provides three categories (Q1, Q2, Q3) and two value columns. The macro renders a grouped bar chart with two bars per category.
114
115 == Children Macro {{id name="children-macro" /}}==
116
117 The **Children** macro displays a list of child pages of the current page in a tree or list format​:contentReference[oaicite:9]{index=9}. It's useful for automatically listing sub-pages without manual updates.
118
119 **Example:** Listing child pages
120
121 *. [[Child Page 1>>#]]
122 *. [[Child Page 2>>#]]
123
124 **Source:**
125
126
127 {{code}}
128 {{children/}}
129 {{/code}}
130
131 In this example, {{code}}{{children/}}{{/code}} would produce a bulleted list of links to all pages that are children of the current page.
132
133 == Code Macro {{id name="code-macro" /}}==
134
135 The **Code** macro formats and highlights a section of source code text. It supports many programming languages via syntax highlighting​:contentReference[oaicite:10]{index=10}, which can be specified with the {{code}}language{{/code}} parameter. By default, it will attempt to detect the language if not provided​:contentReference[oaicite:11]{index=11}. You can also choose to show line numbers by setting {{code}}layout="linenumbers"{{/code}}.
136
137 **Example:** Highlighting a Java code snippet
138
139
140 {{code}}
141 // Java example public class Hello { public static void main(String[] args) { System.out.println("Hello World"); } }
142 {{/code}}
143
144 **Source:**
145
146
147 {{code}}
148 {{code language="java"}} public class Hello { public static void main(String[] args) { System.out.println("Hello World"); } } {{/code}}
149 {{/code}}
150
151 In the rendered output, the code would be syntax-colored for Java. If you wanted to add line numbers to the code block, you could use {{code}}layout="linenumbers"{{/code}}, for example:
152
153
154 {{code}}
155 {{code language="java" layout="linenumbers"}} ... code ... {{/code}}
156 {{/code}}
157
158 == Comment Macro {{id name="comment-macro" /}}==
159
160 The **Comment** macro allows putting comments in the wiki source that will not be displayed in the page output​:contentReference[oaicite:12]{index=12}. It's useful for leaving notes or temporarily hiding content. The content inside the comment macro is completely omitted when rendering the page.
161
162 **Example:** Using a comment to hide content
163
164 Visible part 1. Visible part 2.
165 **Source:**
166
167
168 {{code}}
169 Visible part 1. {{comment}}This text will not be visible{{/comment}} Visible part 2.
170 {{/code}}
171
172 In the above example, the text inside the {{code}}{{comment}}{{/code}} macro ("This text will not be visible") is omitted from the output, so the two visible parts appear consecutively as if the commented text wasn’t there.
173
174 == Container Macro {{id name="container-macro" /}}==
175
176 The **Container** macro groups content and applies a layout to it (such as arranging content in columns)​:contentReference[oaicite:13]{index=13}​:contentReference[oaicite:14]{index=14}. By default, it can implement a {{code}}columns{{/code}} layout (responsive, side-by-side columns) via {{code}}layoutStyle="columns"{{/code}}​:contentReference[oaicite:15]{index=15}. Content for each column is separated by wiki group markers {{code}}(((...))){{/code}} inside the macro.
177
178 **Example:** Two-column layout
179
180 |= |=
181 |**Column 1:** This is the content of the first column. |**Column 2:** This is the content of the second column.
182
183 **Source:**
184
185
186 {{code}}
187 {{container layoutStyle="columns"}} (((**Column 1:** This is the content of the first column.))) (((**Column 2:** This is the content of the second column.))) {{/container}}
188 {{/code}}
189
190 The above will render two columns of content. The container is responsive, so on a narrow screen the columns would stack vertically​:contentReference[oaicite:16]{index=16}. The triple parentheses {{code}}((...)){{/code}} are used to delineate each column’s content within the container macro.
191
192 == Dashboard Macro {{id name="dashboard-macro" /}}==
193
194 The **Dashboard** macro defines a dashboard area into which you can add gadgets​:contentReference[oaicite:17]{index=17}. It's commonly used on overview pages to lay out multiple gadgets in columns. The macro can take a {{code}}columns{{/code}} parameter to specify the number of gadget columns.
195
196 **Example:** A dashboard with 2 columns
197
198 //(Gadget area 1)//
199 //(Gadget area 2)//
200 **Source:**
201
202
203 {{code}}
204 {{dashboard columns="2"/}}
205 {{/code}}
206
207 In practice, you would add gadgets (such as activity streams, charts, etc.) to the dashboard through the UI. The macro itself mainly sets up the layout for those gadgets.
208
209 == Display Macro {{id name="display-macro" /}}==
210
211 The **Display** macro includes the rendered content of another page into the current page​:contentReference[oaicite:18]{index=18}. Unlike the Include macro, it inserts the output as if viewing that page, preserving its internal links and references​:contentReference[oaicite:19]{index=19}. Use this when you want to embed a page's content exactly as it appears on its own.
212
213 **Example:** Display another page’s content
214
215 **Source:**
216
217
218 {{code}}
219 {{display page="Help.Macros"/}}
220 {{/code}}
221
222 This will insert the rendered content of the //Help.Macros// page at this location. All headings, images, and links from that page will appear as they do on the original page.
223
224 == DisplayIcon Macro {{id name="displayicon-macro" /}}==
225
226 The **DisplayIcon** macro inserts an icon from the XWiki icon set into the page​:contentReference[oaicite:20]{index=20}. You specify the icon by its name (and optionally the icon set if different from the default).
227
228 **Example:** Inserting a “home” icon
229
230 🏠 Home
231 **Source:**
232
233
234 {{code}}
235 {{displayIcon name="home"/}} Home
236 {{/code}}
237
238 In this example, the macro {{code}}{{displayIcon name="home"/}}{{/code}} outputs a home icon (the little house symbol before the word "Home"). You can change the {{code}}name{{/code}} to any available icon name in your wiki’s icon theme (for example, {{code}}user{{/code}}, {{code}}document{{/code}}, etc.).
239
240 == Documents Macro {{id name="documents-macro" /}}==
241
242 The **Documents** macro displays a list of pages in a livetable (a dynamic, filterable table of results)​:contentReference[oaicite:21]{index=21}. By default it can show all pages, but you can filter to a specific space or other criteria using parameters.
243
244 **Example:** Listing all pages in a space
245
246 |=Page |=Modified
247 |[[Page1>>#]] |2025/04/15
248 |[[Page2>>#]] |2025/04/10
249
250 **Source:**
251
252
253 {{code}}
254 {{documents space="MySpace"/}}
255 {{/code}}
256
257 This will create a livetable listing all pages in the //MySpace// space, with columns such as page name and last modified date. The table allows sorting and filtering (as it’s a livetable). If you omit the {{code}}space{{/code}} parameter, the macro might list pages from the whole wiki (use with caution on large wikis).
258
259 == DocumentTree Macro {{id name="documenttree-macro" /}}==
260
261 The **DocumentTree** macro displays a collapsible tree of pages​:contentReference[oaicite:22]{index=22}. It’s often used for navigation menus or page indexes. By default, it shows the page hierarchy of the current wiki, but you can specify a different root.
262
263 **Example:** Page tree starting from a given page
264
265 *. **Help (space)**
266 **. Getting Started
267 **. Macros
268 ***. Examples
269 ***. Reference
270
271 **Source:**
272
273
274 {{code}}
275 {{documentTree reference="Help.WebHome"/}}
276 {{/code}}
277
278 In the above example, the tree would start at the //Help// space’s home page and display its descendants. The user can expand/collapse branches. If no reference is specified, the macro may display the entire wiki’s page structure by default.
279
280 == Footnote Macro {{id name="footnote-macro" /}}==
281
282 The **Footnote** macro inserts a footnote marker and text that will be collected and displayed at the bottom of the page​:contentReference[oaicite:23]{index=23} (or at the position of a {{code}}putFootnotes{{/code}} macro). Each footnote will be automatically numbered.
283
284 **Example:** Adding a footnote to a sentence
285
286 This is a statement^^[1]^^ with a reference.\\[1] Source: Example Reference
287 **Source:**
288
289
290 {{code}}
291 This is a statement{{footnote}}Source: Example Reference{{/footnote}} with a reference. {{putFootnotes/}}
292 {{/code}}
293
294 In the above example, the text inside {{code}}{{footnote}}{{/code}} (“Source: Example Reference”) will appear as a numbered footnote at the bottom of the page. The {{code}}{{putFootnotes/}}{{/code}} macro (used here at the end) outputs the collected footnotes. If {{code}}putFootnotes{{/code}} is not explicitly used, all footnotes are automatically shown at the end of the page by default​:contentReference[oaicite:24]{index=24}.
295
296 == PutFootnotes Macro {{id name="putfootnotes-macro" /}}==
297
298 The **PutFootnotes** macro outputs all accumulated footnotes in the page at the location where it is placed​:contentReference[oaicite:25]{index=25}. If this macro is not used, footnotes will appear automatically at the very end of the page by default.
299
300 **Example:** Placing footnotes at a custom location
301
302 **Source:**
303
304
305 {{code}}
306 ... page content ... {{putFootnotes/}}
307 {{/code}}
308
309 Typically, you would put {{code}}{{putFootnotes/}}{{/code}} at the bottom of your content (or wherever you want the footnotes to appear). It will generate a list of all footnotes added via the {{code}}{{footnote}}{{/code}} macro in the text.
310
311 == Gallery Macro {{id name="gallery-macro" /}}==
312
313 The **Gallery** macro displays a collection of images as a gallery or slide-show view​:contentReference[oaicite:26]{index=26}. You supply the images in the macro content (as image references or attachments), and the macro will present them with navigation controls.
314
315 **Example:** A simple image gallery
316
317 [[image:https://www.xwiki.org/logo.png||alt="Image1"]] [[image:https://www.xwiki.org/logo.png||alt="Image2"]]
318 (Images displayed in a gallery with navigation controls)
319
320 **Source:**
321
322
323 {{code}}
324 {{gallery}} image:Space.Page@Image1.png image:Space.Page@Image2.png {{/gallery}}
325 {{/code}}
326
327 In this example, two images (Image1.png and Image2.png from //Space.Page//) will be displayed in a gallery. In view mode, the gallery macro would show the first image with controls to navigate to the next image, or it might display thumbnails of both depending on configuration. You can include images from attachments (using {{code}}image:Page@file{{/code}} syntax) or external images (using {{code}}image:http://...{{/code}}).
328
329 == Groovy Macro {{id name="groovy-macro" /}}==
330
331 The **Groovy** macro executes a Groovy script on the server side​:contentReference[oaicite:27]{index=27}. This macro requires programming rights on the wiki, as it can perform advanced operations. It’s often used to manipulate or retrieve data and then output results in the page.
332
333 **Example:** A simple Groovy script printing a message
334
335 {{code}}Hello from Groovy!{{/code}}
336 **Source:**
337
338
339 {{code}}
340 {{groovy}} println("Hello from Groovy!"); {{/groovy}}
341 {{/code}}
342
343 **Example:** Using Groovy to access XWiki API
344
345 {{code}}This page is: {{/code}}//{{code}}Sample.Page{{/code}}//
346 **Source:**
347
348
349 {{code}}
350 {{groovy}} def doc = xcontext.getDoc(); println("This page is: " + doc.getFullName()); {{/groovy}}
351 {{/code}}
352
353 In the second example, the Groovy script obtains the current document and prints its full name. Groovy scripts can use XWiki's API (via {{code}}xwiki{{/code}}, {{code}}xcontext{{/code}}, etc.) to interact with the wiki.
354
355 == HTML Macro {{id name="html-macro" /}}==
356
357 The **HTML** macro allows inserting raw HTML or XHTML content directly into a wiki page​:contentReference[oaicite:28]{index=28}. This is useful for embedding external widgets or custom HTML that the wiki syntax doesn’t support. (Using this macro may require programming rights to avoid security risks such as XSS.)
358
359 **Example:** Inserting a custom HTML snippet
360
361 This is red text via HTML.
362 **Source:**
363
364
365 {{code}}
366 {{html}} This is red text via HTML. {{/html}}
367 {{/code}}
368
369 **Example:** Embedding an iframe (e.g., a YouTube video)
370
371
372 **Source:**
373
374
375 {{code}}
376 {{html}} {{/html}}
377 {{/code}}
378
379 In the above, the HTML macro is used to embed a video player by directly writing an {{code}}<iframe>{{/code}} tag. The wiki will include that HTML as-is in the rendered page.
380
381 == Id Macro {{id name="id-macro" /}}==
382
383 The **Id** macro defines an anchor in the page that you can link to​:contentReference[oaicite:29]{index=29}. It is similar to an HTML anchor {{code}}<a id="..."></a>{{/code}}. This is helpful for creating link targets (for example, for internal page navigation).
384
385 **Example:** Creating and linking to an anchor
386
387 Click [[here>>#myanchor]] to jump. ...\\{{id name="myanchor" /}}**Target Location:** You have reached the target.
388 **Source:**
389
390
391 {{code}}
392 Click [[here>>#myanchor]] to jump. ... {{id name="myanchor"/}}**Target Location:** You have reached the target.
393 {{/code}}
394
395 In this example, the {{code}}{{id name="myanchor"/}}{{/code}} macro defines an anchor named "myanchor" right before the "Target Location" text. The link {{code}}[[here>>#myanchor]]{{/code}} will scroll to that location when clicked.
396
397 == Include Macro {{id name="include-macro" /}}==
398
399 The **Include** macro includes the content of another wiki page into the current page, as if it were written here​:contentReference[oaicite:30]{index=30}. By default, it acts as if the included content is part of the current page (e.g., relative links in the included content won’t resolve to the original page)​:contentReference[oaicite:31]{index=31}.
400
401 **Example:** Including a page
402
403 **Source:**
404
405
406 {{code}}
407 {{include page="Help.Introduction"/}}
408 {{/code}}
409
410 This will insert the content of the //Help.Introduction// page in-line. If that page has section anchors or relative image links, they might need special handling because the included content is merged into the current page context. If you want to include the fully rendered page instead, consider using the {{code}}display{{/code}} macro.
411
412 **Example:** Including a specific section of a page
413
414 **Source:**
415
416
417 {{code}}
418 {{include page="Help.Macros" section="HExamples"/}}
419 {{/code}}
420
421 Here only the section of //Help.Macros// with the heading "Examples" (and its subcontent) will be included. The {{code}}section{{/code}} parameter uses the anchor name of the heading (XWiki automatically generates anchor IDs like {{code}}HHeadingName{{/code}} for each heading).
422
423 == Mention Macro {{id name="mention-macro" /}}==
424
425 The **Mention** macro allows you to mention a user in content, similar to an @-mention on social platforms. It will typically display the user’s name and trigger a notification to that user.
426
427 **Example:** Mentioning a user
428
429 @John Doe
430 **Source:**
431
432
433 {{code}}
434 {{mention user="xwiki:JohnDoe"/}}
435 {{/code}}
436
437 In the example, {{code}}{{mention user="xwiki:JohnDoe"/}}{{/code}} would produce an @-mention for the user with the username //JohnDoe// (on the //xwiki// wiki). The exact syntax for the user reference may include the wiki and space depending on your configuration. When rendered, it shows the user's name (or profile link), and the user would get a notification that they were mentioned.
438
439 == Notifications Macro {{id name="notifications-macro" /}}==
440
441 The **Notifications** macro displays a feed of recent events (like edits, comments, etc.) on the wiki​:contentReference[oaicite:32]{index=32}. This is usually what you see in the "Activity" or "Notifications" panel on the dashboard. It respects the current user's notification preferences and permissions.
442
443 **Example:** Showing recent wiki notifications
444
445 **Source:**
446
447
448 {{code}}
449 {{notifications/}}
450 {{/code}}
451
452 Using {{code}}{{notifications/}}{{/code}} will embed a live notifications feed. Users will see a list of recent events with options to filter or mark as read, similar to the main Notifications panel.
453
454 == Office Macro {{id name="office-macro" /}}==
455
456 The **Office** macro displays an office document (such as a Word, Excel, or PowerPoint file) directly within a wiki page​:contentReference[oaicite:33]{index=33}. The document must be attached to the wiki (or accessible via a reference). The macro will render the content (for example, using an Office viewer or PDF conversion) so users can read it without downloading.
457
458 **Example:** Embedding an attached Word document
459
460 **Source:**
461
462
463 {{code}}
464 {{office attachment="Main.UserGuide@Guide.docx"/}}
465 {{/code}}
466
467 This will display the //Guide.docx// file attached to the //Main.UserGuide// page. The content of the document will be shown (users can scroll through the pages of the document on the wiki page). Supported file formats include Word documents (.doc/.docx), Excel spreadsheets, PowerPoint presentations, OpenOffice/LibreOffice formats (odt, ods, odp), etc.​:contentReference[oaicite:34]{index=34}.
468
469 == Python Macro {{id name="python-macro" /}}==
470
471 The **Python** macro executes a Python script on the server side​:contentReference[oaicite:35]{index=35}. This requires a Python scripting engine to be installed (such as Jython). Like the Groovy macro, it needs programming rights and can interact with the XWiki API.
472
473 **Example:** A simple Python script
474
475 {{code}}Hello from Python!{{/code}}
476 **Source:**
477
478
479 {{code}}
480 {{python}} print("Hello from Python!") {{/python}}
481 {{/code}}
482
483 If the Python macro is enabled and a Python engine is available, the above would output “Hello from Python!”. You can use the XWiki Python API (similar to the Groovy example) to work with the wiki's content within the script.
484
485 == Script Macro {{id name="script-macro" /}}==
486
487 The **Script** macro executes a script in a specified scripting language​:contentReference[oaicite:36]{index=36}. It is a generic container for different script types (Velocity, Groovy, Python, etc.) controlled by the {{code}}language{{/code}} parameter.
488
489 **Example:** Using the Script macro for a Velocity script
490
491 {{code}}Hello Velocity!{{/code}}
492 **Source:**
493
494
495 {{code}}
496 {{script language="velocity"}} #set($name = "Velocity") Hello $name! {{/script}}
497 {{/code}}
498
499 This does the same as writing a Velocity macro block. The Script macro is handy when you want to dynamically choose the language or when including code from an external source using its {{code}}source{{/code}} parameter (for instance, {{code}}{{script language="groovy" source="document:Space.Page"/}}{{/code}} to run a Groovy script from another page). In most cases, using the dedicated language macro (like {{code}}{{velocity}}{{/code}} or {{code}}{{groovy}}{{/code}}) is simpler.
500
501 == Tag Cloud Macro {{id name="tag-cloud-macro" /}}==
502
503 The **Tag Cloud** macro shows a cloud of tags, where the size of each tag indicates its frequency in the wiki (or in a specific space)​:contentReference[oaicite:37]{index=37}. This provides a visual overview of popular tags.
504
505 **Example:** Tag cloud for the whole wiki
506
507 tag1 tag2 tag3 ...
508 **Source:**
509
510
511 {{code}}
512 {{tagcloud/}}
513 {{/code}}
514
515 This will display a tag cloud of all tags in the wiki. To limit to a specific space, use the {{code}}space{{/code}} parameter. For example, {{code}}{{tagcloud space="Blog"/}}{{/code}} would show tags just from pages in the Blog space.
516
517 == Table of Contents (TOC) Macro {{id name="table-of-contents-toc-macro" /}}==
518
519 The **TOC** macro generates a table of contents for the headings in the page​:contentReference[oaicite:38]{index=38}. It is often used at the top of a page to list its sections. You can customize it with parameters like {{code}}start{{/code}} level, {{code}}depth{{/code}}, and whether to number the headings.
520
521 **Example:** Basic TOC
522
523 *. Introduction
524 *. Details
525 **. Subsection
526 *. Conclusion
527
528 **Source:**
529
530
531 {{code}}
532 {{toc/}}
533 {{/code}}
534
535 This will insert a table of contents listing all headings in the page.
536
537 **Example:** TOC starting from level 2 headings
538
539 **Source:**
540
541
542 {{code}}
543 {{toc start="2" numbered="true"/}}
544 {{/code}}
545
546 In this second example, the TOC will skip level 1 headings and start at level 2, and the entries will be numbered. For instance, a level 2 heading will be labeled “1.”, its level 3 subheading “1.1”, and so on.
547
548 == User Avatar Macro {{id name="user-avatar-macro" /}}==
549
550 The **UserAvatar** macro displays the avatar image of a specified user​:contentReference[oaicite:39]{index=39}. You can use this to show user pictures in pages (for example, in comments or user listings).
551
552 **Example:** Showing a user's avatar
553
554 [[image:https://www.xwiki.org/xwiki/bin/download/Static/Icons/user.png||alt="Avatar"]] John Doe
555 **Source:**
556
557
558 {{code}}
559 {{useravatar user="xwiki:JohnDoe"/}} John Doe
560 {{/code}}
561
562 In this example, {{code}}{{useravatar user="xwiki:JohnDoe"/}}{{/code}} would display the profile avatar of the user //JohnDoe// (with a default icon if the user hasn’t set one). You can adjust the size via parameters if needed (e.g., {{code}}size="large"{{/code}} for a larger avatar), depending on the macro's implementation.
563
564 == Velocity Macro {{id name="velocity-macro" /}}==
565
566 The **Velocity** macro executes a Velocity script on the server side​:contentReference[oaicite:40]{index=40}. Velocity is the default scripting language for XWiki and can be used without explicitly using this macro (since wiki pages themselves can contain Velocity code enclosed in {{code}}{{velocity}}{{/code}}... by default if allowed). However, using the macro explicitly can control scope and avoid interference with other syntax.
567
568 **Example:** A simple Velocity script
569
570 {{code}}Hello Alice!{{/code}}
571 **Source:**
572
573
574 {{code}}
575 {{velocity}} #set($name = "Alice") Hello $name! {{/velocity}}
576 {{/code}}
577
578 This will output “Hello Alice!”. In Velocity, variables are defined with {{code}}#set{{/code}} and referenced with {{code}}${{/code}}. Velocity has access to many predefined variables (like {{code}}$doc{{/code}} for the current document, {{code}}$services{{/code}}, etc.) in XWiki’s context.
579
580 == Menu Macro {{id name="menu-macro" /}}==
581
582 The **Menu** macro can generate a navigation menu from a nested list of links. You provide the menu structure in wiki syntax (using nested bullet points) inside the macro, and it will render it as a styled menu.
583
584 **Example:** Simple menu
585
586 *. [[Home>>#]]
587 *. [[Products>>#]]
588 **. [[Product A>>#]]
589 **. [[Product B>>#]]
590 *. [[Contact>>#]]
591
592 **Source:**
593
594
595 {{code}}
596 {{menu}} * [[Home>>Main.WebHome]] * [[Products>>Main.Products]] ** [[Product A>>Main.Products.ProductA]] ** [[Product B>>Main.Products.ProductB]] * [[Contact>>Main.Contact]] {{/menu}}
597 {{/code}}