How do I add a custom button in the AEM toolbar? | Community
Skip to main content
vigiaemnewbie
Level 2
Dec 21, 2018 11:43 AM UTC
Solved

How do I add a custom button in the AEM toolbar?

I need to add two custom buttons along with the "Edit" and "Preview" buttons on the AEM toolbar at the top. One button will push the content to a preview environment and one button will push the content to the production environment after the approval of an authorized member.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Dec 21, 2018 2:05 PM UTC

You may need to overlay /libs/wcm/core/content/editor/jcr:content/content/items/content/header/items/headerbar/items

and add two new node of resourceType granite/ui/components/coral/foundation/button

I never tried this but you can check existing flow in order to make it work properly

Arun Patidar

7 replies

vigiaemnewbie
Level 2
Dec 27, 2018 6:09 AM UTC

Thanks Arun,

Assigned a granite:id to each of my buttons and triggered an ajax call on click.

Translate
arunpatidar
New Participant
Dec 24, 2018 1:08 PM UTC

Hi,

You need to create clientlibs with category of 'cq.authoring.editor' there you can call servlet based on onclick.

You can give any unique class(granite:class) or id(granite:id) and based on that you can register Javascript on click event for those two buttons.

Translate
Arun Patidar
vigiaemnewbie
Level 2
Dec 24, 2018 12:43 PM UTC

But where do I put my script that makes the call? I am not able to find where AEM is triggering actions for the already existing buttons on the page, although it is clear that the "granite:class" property is populating the class attribute when the AEM user interface is rendered in authoring and AEM is using these classes to identify when it is clicked to trigger the preview or edit mode, but where are these scripts and how can I add my ajax call under /apps/?

Translate
arunpatidar
New Participant
Dec 24, 2018 12:32 PM UTC

Hi,

On click of those buttons you can invoke servlet using ajax call which will trigger the workflows.

you can return response as well to show details in Alert  like Documentation | CoralUI

Translate
Arun Patidar
vigiaemnewbie
Level 2
Dec 24, 2018 8:29 AM UTC

Thanks Arun,

I was able to overlay the buttons and add my own two buttons for preview build and production build. I need to trigger a workflow when I click these buttons. I have copied the "Preview" button node and modified according to my needs but it seems this node is using the below properties to trigger the preview mode during authoring. How can I trigger my workflow from this node, i.e., when the author clicks on these respective buttons on the authoring screen?

Node properties:

How the buttons appear on the authoring page:

Translate
smacdonald2008
Level 10
Dec 21, 2018 4:02 PM UTC
arunpatidar
arunpatidarAccepted solution
New Participant
Dec 21, 2018 2:05 PM UTC

You may need to overlay /libs/wcm/core/content/editor/jcr:content/content/items/content/header/items/headerbar/items

and add two new node of resourceType granite/ui/components/coral/foundation/button

I never tried this but you can check existing flow in order to make it work properly

Translate
Arun Patidar