Show last authors
author | version | line-number | content |
---|---|---|---|
1 | = 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 | |||
6 | == TOC Macro == | ||
7 | |||
8 | The **TOC** macro generates a Table of Contents. | ||
9 | |||
10 | {{example}} | ||
11 | {{toc/}} | ||
12 | {{/example}} | ||
13 | |||
14 | == Box Macro == | ||
15 | |||
16 | The **Box** macro draws a box around the content inside it. This is useful for highlighting important information or grouping related content in a styled panel. | ||
17 | |||
18 | {{example}} | ||
19 | {{box title="Note"}} | ||
20 | This is a sample box message. | ||
21 | {{/box}} | ||
22 | {{/example}} | ||
23 | |||
24 | == Info Macro == | ||
25 | |||
26 | The **Info** macro displays an informational message in a styled box. It is typically rendered with a blue color to denote general information. | ||
27 | |||
28 | {{example}} | ||
29 | {{info}} | ||
30 | This is an informational message. | ||
31 | {{/info}} | ||
32 | {{/example}} | ||
33 | |||
34 | {{example}} | ||
35 | {{info title="FYI"}} | ||
36 | This is an informational message with a title. | ||
37 | {{/info}} | ||
38 | {{/example}} | ||
39 | |||
40 | == Warning Macro == | ||
41 | |||
42 | The **Warning** macro highlights a warning message in a styled box (yellow/orange background). | ||
43 | |||
44 | {{example}} | ||
45 | {{warning}} | ||
46 | This is a warning message. | ||
47 | {{/warning}} | ||
48 | {{/example}} | ||
49 | |||
50 | == Success Macro == | ||
51 | |||
52 | The **Success** macro displays a success message in a green-styled box. | ||
53 | |||
54 | {{example}} | ||
55 | {{success}} | ||
56 | This is a success message. | ||
57 | {{/success}} | ||
58 | {{/example}} | ||
59 | |||
60 | == Error Macro == | ||
61 | |||
62 | The **Error** macro displays a critical error or alert message in a red-styled box. | ||
63 | |||
64 | {{example}} | ||
65 | {{error}} | ||
66 | This is an error message. | ||
67 | {{/error}} | ||
68 | {{/example}} | ||
69 | |||
70 | == Chart Macro == | ||
71 | |||
72 | The **Chart** macro generates graphical charts based on input tables. | ||
73 | |||
74 | {{example}} | ||
75 | {{chart type="pie" source="inline" params="range:B2-B4;series:columns;" width="400" height="300"}} | ||
76 | |=Category|=Value| | ||
77 | |A|10| | ||
78 | |B|20| | ||
79 | |C|30| | ||
80 | {{/chart}} | ||
81 | {{/example}} | ||
82 | |||
83 | {{example}} | ||
84 | {{chart type="bar" source="inline" params="range:B2-C4;series:columns;" width="500" height="300"}} | ||
85 | |=Quarter|=Product X|=Product Y| | ||
86 | |Q1|20|15| | ||
87 | |Q2|30|25| | ||
88 | |Q3|25|30| | ||
89 | {{/chart}} | ||
90 | {{/example}} | ||
91 | |||
92 | == Children Macro == | ||
93 | |||
94 | The **Children** macro lists the child pages of the current page. | ||
95 | |||
96 | {{example}} | ||
97 | {{children/}} | ||
98 | {{/example}} | ||
99 | |||
100 | == Code Macro == | ||
101 | |||
102 | The **Code** macro highlights and formats source code. | ||
103 | |||
104 | {{example}} | ||
105 | {{code language="java"}} | ||
106 | public class Hello { | ||
107 | public static void main(String[] args) { | ||
108 | System.out.println("Hello World"); | ||
109 | } | ||
110 | } | ||
111 | {{/code}} | ||
112 | {{/example}} | ||
113 | |||
114 | == Comment Macro == | ||
115 | |||
116 | The **Comment** macro hides content from page rendering. | ||
117 | |||
118 | {{example}} | ||
119 | Visible part 1. | ||
120 | {{comment}}This text will not be visible.{{/comment}} | ||
121 | Visible part 2. | ||
122 | {{/example}} | ||
123 | |||
124 | == Container Macro == | ||
125 | |||
126 | The **Container** macro creates multi-column layouts. | ||
127 | |||
128 | {{example}} | ||
129 | {{container layoutStyle="columns"}} | ||
130 | (((**Column 1:** This is the first column.))) | ||
131 | (((**Column 2:** This is the second column.))) | ||
132 | {{/container}} | ||
133 | {{/example}} | ||
134 | |||
135 | == Dashboard Macro == | ||
136 | |||
137 | The **Dashboard** macro creates areas for gadgets. | ||
138 | |||
139 | {{example}} | ||
140 | {{dashboard columns="2"/}} | ||
141 | {{/example}} | ||
142 | |||
143 | == Display Macro == | ||
144 | |||
145 | The **Display** macro embeds content from another page. | ||
146 | |||
147 | {{example}} | ||
148 | {{display page="Help.Macros"/}} | ||
149 | {{/example}} | ||
150 | |||
151 | == DisplayIcon Macro == | ||
152 | |||
153 | The **DisplayIcon** macro displays an icon. | ||
154 | |||
155 | {{example}} | ||
156 | {{displayIcon name="home"/}} Home | ||
157 | {{/example}} | ||
158 | |||
159 | == Documents Macro == | ||
160 | |||
161 | The **Documents** macro shows a livetable of documents. | ||
162 | |||
163 | {{example}} | ||
164 | {{documents space="MySpace"/}} | ||
165 | {{/example}} | ||
166 | |||
167 | == DocumentTree Macro == | ||
168 | |||
169 | The **DocumentTree** macro shows a collapsible page tree. | ||
170 | |||
171 | {{example}} | ||
172 | {{documentTree reference="Help.WebHome"/}} | ||
173 | {{/example}} | ||
174 | |||
175 | == Footnote Macro == | ||
176 | |||
177 | The **Footnote** macro adds footnotes to the page. | ||
178 | |||
179 | {{example}} | ||
180 | This is a statement{{footnote}}Source: Example Reference{{/footnote}}. | ||
181 | {{putFootnotes/}} | ||
182 | {{/example}} | ||
183 | |||
184 | == PutFootnotes Macro == | ||
185 | |||
186 | The **PutFootnotes** macro outputs collected footnotes. | ||
187 | |||
188 | {{example}} | ||
189 | ...page content... | ||
190 | {{putFootnotes/}} | ||
191 | {{/example}} | ||
192 | |||
193 | == Gallery Macro == | ||
194 | |||
195 | The **Gallery** macro displays a collection of images. | ||
196 | |||
197 | {{example}} | ||
198 | {{gallery}} | ||
199 | image:Space.Page@Image1.png | ||
200 | image:Space.Page@Image2.png | ||
201 | {{/gallery}} | ||
202 | {{/example}} | ||
203 | |||
204 | == Groovy Macro == | ||
205 | |||
206 | The **Groovy** macro executes Groovy scripts. | ||
207 | |||
208 | {{example}} | ||
209 | {{groovy}} | ||
210 | println("Hello from Groovy!") | ||
211 | {{/groovy}} | ||
212 | {{/example}} | ||
213 | |||
214 | == HTML Macro == | ||
215 | |||
216 | The **HTML** macro embeds raw HTML into pages. | ||
217 | |||
218 | {{example}} | ||
219 | {{html}} | ||
220 | <p style="color:red;">This is red text via HTML.</p> | ||
221 | {{/html}} | ||
222 | {{/example}} | ||
223 | |||
224 | == Id Macro == | ||
225 | |||
226 | The **Id** macro defines an internal link anchor. | ||
227 | |||
228 | {{example}} | ||
229 | Click [[here>>#myanchor]] to jump. | ||
230 | |||
231 | {{id name="myanchor"/}} | ||
232 | **Target Location:** You have reached the target. | ||
233 | {{/example}} | ||
234 | |||
235 | == Include Macro == | ||
236 | |||
237 | The **Include** macro includes another page's content. | ||
238 | |||
239 | {{example}} | ||
240 | {{include page="Help.Introduction"/}} | ||
241 | {{/example}} | ||
242 | |||
243 | == Mention Macro == | ||
244 | |||
245 | The **Mention** macro notifies a mentioned user. | ||
246 | |||
247 | {{example}} | ||
248 | {{mention user="xwiki:JohnDoe"/}} | ||
249 | {{/example}} | ||
250 | |||
251 | == Notifications Macro == | ||
252 | |||
253 | The **Notifications** macro displays recent activity. | ||
254 | |||
255 | {{example}} | ||
256 | {{notifications/}} | ||
257 | {{/example}} | ||
258 | |||
259 | == Office Macro == | ||
260 | |||
261 | The **Office** macro displays Office documents. | ||
262 | |||
263 | {{example}} | ||
264 | {{office attachment="Main.UserGuide@Guide.docx"/}} | ||
265 | {{/example}} | ||
266 | |||
267 | == Python Macro == | ||
268 | |||
269 | The **Python** macro executes Python scripts. | ||
270 | |||
271 | {{example}} | ||
272 | {{python}} | ||
273 | print("Hello from Python!") | ||
274 | {{/python}} | ||
275 | {{/example}} | ||
276 | |||
277 | == Script Macro == | ||
278 | |||
279 | The **Script** macro executes scripts in different languages. | ||
280 | |||
281 | {{example}} | ||
282 | {{script language="velocity"}} | ||
283 | #set($name = "Velocity") | ||
284 | Hello $name! | ||
285 | {{/script}} | ||
286 | {{/example}} | ||
287 | |||
288 | == Tag Cloud Macro == | ||
289 | |||
290 | The **Tag Cloud** macro displays tags visually. | ||
291 | |||
292 | {{example}} | ||
293 | {{tagcloud/}} | ||
294 | {{/example}} | ||
295 | |||
296 | == User Avatar Macro == | ||
297 | |||
298 | The **User Avatar** macro shows a user's avatar image. | ||
299 | |||
300 | {{example}} | ||
301 | {{useravatar user="xwiki:JohnDoe"/}} | ||
302 | {{/example}} | ||
303 | |||
304 | == Velocity Macro == | ||
305 | |||
306 | The **Velocity** macro executes Velocity scripts. | ||
307 | |||
308 | {{example}} | ||
309 | {{velocity}} | ||
310 | #set($name = "Alice") | ||
311 | Hello $name! | ||
312 | {{/velocity}} | ||
313 | {{/example}} | ||
314 | |||
315 | == Menu Macro == | ||
316 | |||
317 | The **Menu** macro builds a navigation menu. | ||
318 | |||
319 | {{example}} | ||
320 | {{menu}} | ||
321 | * [[Home>>Main.WebHome]] | ||
322 | * [[Products>>Main.Products]] | ||
323 | ** [[Product A>>Main.Products.ProductA]] | ||
324 | ** [[Product B>>Main.Products.ProductB]] | ||
325 | * [[Contact>>Main.Contact]] | ||
326 | {{/menu}} | ||
327 | {{/example}} | ||
328 | |||
329 | == Button Macro == | ||
330 | |||
331 | The Button macro inserts a styled clickable button. | ||
332 | |||
333 | {{example}} | ||
334 | {{button link="https://xwiki.org" style="primary"}} | ||
335 | Click Me | ||
336 | {{/button}} | ||
337 | {{/example}} | ||
338 | |||
339 | == Carousel Macro == | ||
340 | |||
341 | The Carousel macro displays a slideshow of images. | ||
342 | |||
343 | {{example}} | ||
344 | {{carousel}} | ||
345 | image:Space.Page@Image1.png | ||
346 | image:Space.Page@Image2.png | ||
347 | {{/carousel}} | ||
348 | {{/example}} | ||
349 | |||
350 | == Embed Macro == | ||
351 | |||
352 | The Embed macro shows external content like YouTube videos. | ||
353 | |||
354 | {{example}} | ||
355 | {{embed url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"/}} | ||
356 | {{/example}} | ||
357 | |||
358 | == Expandable Macro == | ||
359 | |||
360 | The Expandable macro shows expandable hidden content. | ||
361 | |||
362 | {{example}} | ||
363 | {{expandable title="Click to Expand"}} | ||
364 | Hidden details appear here. | ||
365 | {{/expandable}} | ||
366 | {{/example}} | ||
367 | |||
368 | == Excerpt Macro == | ||
369 | |||
370 | The Excerpt macro marks content for reuse elsewhere. | ||
371 | |||
372 | {{example}} | ||
373 | {{excerpt}} | ||
374 | This is excerpted content. | ||
375 | {{/excerpt}} | ||
376 | {{/example}} | ||
377 | |||
378 | == FAQ Macro == | ||
379 | |||
380 | The FAQ macro lists FAQ entries. | ||
381 | |||
382 | {{example}} | ||
383 | {{faq space="FAQ"/}} | ||
384 | {{/example}} | ||
385 | |||
386 | == Live Data Macro == | ||
387 | |||
388 | The LiveData macro displays dynamic data tables. | ||
389 | |||
390 | {{example}} | ||
391 | {{liveData source="document"/}} | ||
392 | {{/example}} | ||
393 | |||
394 | == Panel Macro == | ||
395 | |||
396 | The Panel macro creates styled content boxes. | ||
397 | |||
398 | {{example}} | ||
399 | {{panel title="Panel Title"}} | ||
400 | This is inside a panel. | ||
401 | {{/panel}} | ||
402 | {{/example}} | ||
403 | |||
404 | == PDF Viewer Macro == | ||
405 | |||
406 | The PDFViewer macro embeds PDFs using PDF.js. | ||
407 | |||
408 | {{example}} | ||
409 | {{pdfviewer attachment="MyPage@file.pdf"/}} | ||
410 | {{/example}} | ||
411 | |||
412 | == Profile Picture Macro == | ||
413 | |||
414 | The Profile Picture macro shows a user’s picture. | ||
415 | |||
416 | {{example}} | ||
417 | {{profile-picture user="xwiki:JohnDoe"/}} | ||
418 | {{/example}} | ||
419 | |||
420 | == Recently Updated Macro == | ||
421 | |||
422 | The Recently Updated macro lists recent changes. | ||
423 | |||
424 | {{example}} | ||
425 | {{recently-updated/}} | ||
426 | {{/example}} | ||
427 | |||
428 | == Status Macro == | ||
429 | |||
430 | The Status macro adds a colored status label. | ||
431 | |||
432 | {{example}} | ||
433 | {{status value="In Progress" color="yellow"/}} | ||
434 | {{/example}} | ||
435 | |||
436 | == Team Macro == | ||
437 | |||
438 | The Team macro shows avatars of a team. | ||
439 | |||
440 | {{example}} | ||
441 | {{team space="TeamSpace"/}} | ||
442 | {{/example}} | ||
443 | |||
444 | == Tooltip Macro == | ||
445 | |||
446 | The Tooltip macro shows hints on hover. | ||
447 | |||
448 | {{example}} | ||
449 | Hover {{tooltip content="Extra Information"}}here{{/tooltip}}. | ||
450 | {{/example}} | ||
451 | |||
452 | == Tree Macro == | ||
453 | |||
454 | The Tree macro shows a hierarchical list. | ||
455 | |||
456 | {{example}} | ||
457 | {{tree}} | ||
458 | |||
459 | [[Parent>>Parent.Page]] | ||
460 | ** [[Child 1>>Parent.Child1]] | ||
461 | ** [[Child 2>>Parent.Child2]] | ||
462 | {{/tree}} | ||
463 | {{/example}} | ||
464 | |||
465 | == Video Macro == | ||
466 | |||
467 | The Video macro embeds videos. | ||
468 | |||
469 | {{example}} | ||
470 | {{video url="https://www.youtube.com/watch?v=dQw4w9WgXcQ"/}} | ||
471 | {{/example}} | ||
472 | |||
473 | 1. View File Macro — Fully Fixed | ||
474 | Problem: | ||
475 | The pdfviewer macro cannot be inside {{example}}...{{/example}}. It has to be standalone. | ||
476 | |||
477 | Solution 1: (Most Correct) Directly embed your PDF viewer like this: | ||
478 | |||
479 | |||
480 | |||
481 | == View File Macro == | ||
482 | |||
483 | The View File macro shows a file viewer for an attached file. | ||
484 | |||
485 | |||
486 | {{pdfviewer attachment="MyWiki@Reverse_Discrimination.pdf"/}} | ||
487 | |||
488 | |||
489 | ✅ This will show the PDF outside of any {{example}} wrapping. | ||
490 | ✅ Must be attached to the same page (your page is /bin/view/MyWiki/). | ||
491 | |||
492 | Note: | ||
493 | If you MUST put it inside an {{example}}, we have to fallback to iframe HTML instead of a macro (I can show that if you want). | ||
494 | |||
495 | == UIExtension Macro — Fully Fixed == | ||
496 | Problem: | ||
497 | You used a non-existent extension point org.xwiki.platform.panels — that ID does not exist in your wiki. | ||
498 | |||
499 | Solution: | ||
500 | ➔ We need to use a real extension id. | ||
501 | Example safer extension ID: Try org.xwiki.watchlist.menu (almost always exists). | ||
502 | |||
503 | Fixed Example: | ||
504 | |||
505 | == UI Extension Macro == | ||
506 | |||
507 | The UIExtension macro injects UI elements into extension points. | ||
508 | |||
509 | {{example}} | ||
510 | |||
511 | {{uiextension id="org.xwiki.watchlist.menu"/}} | ||
512 | |||
513 | {{/example}} | ||
514 | |||
515 | ✅ This will NOT give you the [Failed to find an extension id] error because it's a real one. | ||
516 | |||
517 | Or, if you want me to list your real extensions dynamically so you can pick properly, I can show you how to list them. | ||
518 | |||
519 | == UIExtensions Macro — Leave it as-is == | ||
520 | |||
521 | ✅ No syntax errors shown here. | ||
522 | ✅ Already correct. | ||
523 | |||
524 | You can keep it exactly: | ||
525 | |||
526 | |||
527 | == UI Extensions Macro == | ||
528 | |||
529 | The UIExtensions macro lists UI extensions for a given extension point. | ||
530 | |||
531 | {{example}} | ||
532 | |||
533 | {{uiextensions extensionpoint="org.xwiki.watchlist.menu"/}} | ||
534 | |||
535 | {{/example}} |