Add 'User Macro' to 'Featured Macros' section of Insert menu

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?

1 answer

1 accepted

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.

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!

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.

Brilliant, thanks Andrew I'll try it out!

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.

Brilliant, followed your instructions and got it working, thanks!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,656 views 24 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you