I am pretty a beginner in coding Confluence User Macros but have some experience in object oriented languages, such as VB and VBA. I never coded HTML, Java or CSS.
Can I include other classes into my code, so I can use more functions, methods and properties. However I cannot find a tutorial to do this in a Confluence User Macro. For example I would like to show the mail address, personal information or phone number of a user.
I found this page that says I can use $config, $rederContext, $space and $content to access to these four classes, and I can use a bunch of other classes as described here . But nothing could yet help me out to display the user information.
(Maybe you can give me a link to a tutorial how to properly use this page. That would be really nice. It's frustrating to find functions I can use in the editor.)
Is it possible to define the data type of an object? Such as Key or User or ProfilePictureInfo etc.?
Can you recommend an IDE to write User Macros or Plugins in Confluence or Jira? I just installed Visual Studio and Eclipse but the Atlassian IDE Connector does'nt seem to be compatible with the actual versions. (I really miss the auto complete function.. :-) )
Thank you in advance!
You have stumbled upon one of the vary powerful, but under-documented features of Confluence. To first give you a simple answer, yes you can included a class. For example, here is a simple macro that sets a class around the text inside the macro:
## Check if the body exists
#set($display = $body.trim())
Then take a look at my answer to a similar question User-Macro-Language-Reference.
It should get you started down the rich and rewarding path of a user macro writer. ;-)
Hey @Bill_Bailey , thank you for your links. i really liked your article regarding the Wrapper Macro. That gave me some inspiration, since the motivation you describe is often like mine, too.
The links to the Velocity Engine showed me that I was already looking at the right places. Mabe I should read that site again more carefully. Thank you, though!
Your code example above ("<p class ...") - as I understand it - defines a new class, right? That will be surely useful later. But my main question is:
--> Can I refer to a chosen class from the Atlassian Confluence API?
Sorry, you said class and I thought CSS. ;-) Yes you have access to Confluence JAVA objects and methods but there are limitations. Here is a list of objects available in the Confluence Velocity context:
You can also add objects to the velocity context with some cleverness (this is not from me - I am not smart enough), for example:
## ContentPropertyManager setup
So that I can do something like this to retrieve data stored by another macro:
## Retrieve doc title from scroll pagetitle macro and clean file name
Hey @Bill_Bailey thank you for your detailed answer. This is exactly what I need to know.
Now just for a last outlook before I'll get "into the doing":
1. Are Plugins or Apps more open regarding those "limitations" compared to user macros?
2. What IDE do you recommend and how to tell it the language reference of confluence?
Yes, plugins give you complete access to the API, but there is more overhead in development.
I tried to use an IDE before but wasn't that useful to me. I currently just use Notepad++ with Velocity language pack. I haven't tried it yet, but @Davin_Studer editor plug in looks promising.
I have used the SDK before for complex macro development as it spins up a dev version of Confluence -- its console gives valuable feedback.
Also, if you are going to be writing user macros I've written a free app in the marketplace for enhancing the user macro editing experience. There are a bunch of features lacking in the user macro exiting experience and I've tried to cover a bunch of the pain points.
Thanks everyone for answering last week’s question. The winner of the random drawing from those who commented is: @LarryBrock I’ll contact you separately with your prize details. This wee...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event
You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events