Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Greg Smith February 21, 2012

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

2 votes
Answer accepted
Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 21, 2012

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.

Greg Smith February 23, 2012

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!

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2012

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.

Greg Smith February 23, 2012

Brilliant, thanks Andrew I'll try it out!

Andrew Frayling
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 23, 2012

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.

Greg Smith February 23, 2012

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events