Add 'User Macro' to 'Featured Macros' section of Insert menu
Asked by Greg Smith:

Hi, I have added a user macro to Confluence which will be frequently used by our staff. I would like to add it to the insert menu (in the featured macros section?) so that it can be used without opening the macro browser and locating it each time. Is this possible?


Answers:
author: Andrew Frayling
body: Hi Greg,

For adding full blown macro plugins to the insert menu there's documentation available at <https://developer.atlassian.com/display/CONFDEV/Plugin+points+for+the+editor+in+4.0> I'm not sure if you can reference a user macro in a Web Item though as I've never tried to do this.

Hope that's of some help as a starting point??

Andrew.

comments: author: Greg Smith
body: Thanks Andrew, I don't think there's the easy way I hoped for to do this. Putting a plugin together seems like overkill, but it might be the only way!


author: Andrew Frayling
body: Hi Greg,

This might be easier than I thought by just using the above link to create a plugin that just creates the menu item, but referencing the key of the user macro rather than having to convert the user macro to a macro plugin. Testing it now to see if it works.

Andrew.


author: Greg Smith
body: Brilliant, thanks Andrew I'll try it out!


author: Andrew Frayling
body: Yep it works with user macros, amazing what some sleep followed by caffeine can do :-)

1. Create your user macro
2. Download and install the Plugin SDK - <https://developer.atlassian.com/display/DOCS/Installing+the+Atlassian+Plugin+SDK>
3. Create a skeleton plugin - <https://developer.atlassian.com/display/DOCS/Create+a+Plugin+Skeleton>
4. Edit pom.xml to provide your company name, URL and description
5. Delete the ExampleMacro.java file that the SDK creates
6. Edit atlassian-plugin.xml so it's similar to the following:

```
<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">    <plugin-info>        <description>${project.description}</description>        <version>${project.version}</version>        <vendor name="${project.organization.name}" url="${project.organization.url}" />    </plugin-info>            <web-item key="editor-my-macro" name="Insert Last Login MAcro" section="system.editor.featured.macros.default" weight="100">        <label key="Last Login Macro"/>        <link linkId="lastlogin"/>    </web-item></atlassian-plugin>
```

In the above example I tested with a user macro that I had created called "lastlogin" so just replace the label key and linkid with values that match your user macro.

7. Type atlas-run to run up a test instance of Confluence including the new item  
8. Add you user macro to the test instance  
9. Test that the menu item works  
10. Run atlas-package to package your plugin so it can be installed on your real Confluence instance

NB. The macro browser only works with macros that have parameters so if your user macro does not have parameters that the user has to enter it won't work with the macro browser in general let alone via the new menu item.

Hope that makes sense? A bit of a rushed set of instructions as I need to head out, but I'll blog a more detailed solution and post it later.

Andrew.


author: Greg Smith
body: Brilliant, followed your instructions and got it working, thanks!