Can I use an image as a button for the Create From Template macro?

Similar to this old post I am trying to improve the look of a page by using images as buttons. When I generate a button via the 'create from template' macro and then take the URL is has and insert it as the URL for an image, it doesn't work. When I then click the image, it just takes me back to the dashboard of the Confluence instance I am using. The original button works fine when I click it though.

The URL the button generate looks like this: http://example.com:8080/?createDialogSpaceKey=SBV2&createDialogBlueprintId=XXXX-XXXXX-XXXX

1 answer

1 accepted

You could create a user macro to wrap your "create from template" button to override the styles on it.

Macro Body Processing:
Rendered

Template:

## Developed by: Davin Studer
## Date created: 07/15/2015
## @param Image:title=Image URL|type=string|required=true|desc=The URL to the image.
## @param Width:title=Image Width|type=string|required=true|desc=The width of the image in px. (ex. 98)
## @param Height:title=Image Height|type=string|required=true|desc=The height of the image in px. (ex. 98)

#set( $id = $action.dateFormatter.calendar.timeInMillis )

<span id="button${id}">${body}</span>
<style>
#button${id} .aui-button.create-from-template-button, #button${id} .aui-button.create-from-template-button:active, #button${id} .aui-button.create-from-template-button:focus {
    background: url('${paramImage}') no-repeat;
    border: 0;
    text-indent: -999em;
    width: ${paramWidth}px;
    height: ${paramHeight}px;
    box-shadow: none;
    border-radius: 0;
}
</style>

 

Update: Added screenshot

image2015-7-15 16:28:44.png

Thanks for the suggestion. Would this work if I have multiple buttons on the same page? If it's not too much trouble could you expand on how I would apply this as I am pretty fresh to Confluence.

Davin Studer Community Champion Jul 15, 2015

It should work just fine with multiple create from template button ... although I have not tried it. You just need to create a user macro (Confluence Admin -> User Macros) and use the above code. Then put the user macro on the page, fill in the macro parameters, and put your create from template macro inside it. See the above screen shot that I have added.

Awesome! Works great, thanks heaps for throwing that together. Any tips on how I can get the buttons side by side with a small gap between them? At the moment your wrapper macro takes up an entire line and when the page saves the buttons are all on top of each other. I've tried leaving no gap and not putting a space but no dice.

Oh and my sharp cornered buttons now have a tiny curve on their corners now. No big deal, just letting you know.

Davin Studer Community Champion Jul 16, 2015

I have edited the above user macro for your issues. The corner should not be rounded anymore. Also, when rendered they should show next to each other (inline). In the editor they won't be on the same line, but they should render on the same line when viewing the page.

Legend. Works perfectly now. Really appreciate that mate. My only dilemma now is that I have 2 buttons that use the Create from Template macros and one that is just an image with the createBlogpost URL behind it. Since the image does not have the macro wrapping around it, it is not aligned with the other 2 images on the page. Ill have to figure out how to align it without applying the code in your above macro.

I solved this by inserting the 3 column page layout area at the top of the page. If I put each button in it's own column and then have the rest of the page's macros and blueprints under these in the normal page layouts I can have them evenly spaced and on the same horizontal plane!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Confluence

Three common content challenges + how to manage them

An efficient enterprise content management system, or ECM, is a must-have for companies that create work online (cough   cough, all companies). If content calendars, marketing plans, and bu...

89 views 0 6
Read article

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