Last modified by Simon Urli on 2023/10/10

From version 41.1
edited by Asiri Rathnayake
on 2009/07/21
Change comment: Upload new image <a href="/xwiki/bin/downloadrev/DevGuide/WikiMacroTutorial/macro4.png?rev=1.1">macro4.png</a>
To version 44.1
edited by Asiri Rathnayake
on 2009/07/21
Change comment: There is no comment for this version



Page properties
... ... @@ -47,8 +47,23 @@
47 47  
48 48  1.1.1 Parameters
49 49  
50 +Introducing a parameter to a wiki macro is pretty straight forward; you simply need to add an object of type XWiki.WikiMacroParameterClass into your wiki macro document (one object per parameter). This class contains several fields that allows you to define your parameter clearly:
51 +
52 +* Parameter name: Name of the parameter, users will refer this name when invoking your macro with parameters
53 +
54 +* Parameter description: A short description of the parameter, this description will be made available on the WYSIWYG editor
55 +
56 +* Parameter mandatory: Indicates if this particular parameter is mandatory, wiki macro will fail to execute if a mandatory parameter is missing
57 +
58 +Now we're going to extend our hello macro with a parameter. We will introduce a parameter named ~~greetUser~~ that will indicate if the greeting message should be tailored for current user viewing the page. The definition of the parameter is show below:
59 +
60 +{image:macro3.png}
61 +
50 50  #error("This section is being updated")
51 51  
64 +
65 +
66 +
52 52  1.1 WYSIWYG Access
53 53  
54 54  A wiki macros is treated just like any other rendering macro in the system. As such, the moment you save your wiki macro it will be available to the users through the WYSIWYG editor's *Insert Macro* dialog box:

Get Connected