Expand my Community achievements bar.

SOLVED

Adding a Button to Sidekick: Content Finder Interference?

Avatar

Former Community Member

I'm trying to add a custom button to the sidekick that simply launches a dialog. I'm having a weird issue where the JS to add the button doesn't work (no JS errors in the console) unless I remove the content finder by removing /cf#/ from the URL. Obviously, I'm talking about author mode.

There are a number of ways to add to the sidekick. I did so by replacing the default include of init.jsp (in head.jsp) with this file, which is my own init.jsp in my page component:

<%@include file="/apps/myapp/components/global.jsp" %> <cq:include script="/libs/wcm/core/components/init/init.jsp" /> <c:if test="${isAuthor}"> <script type="text/javascript"> (function() { CQ.wcm.Sidekick.DEFAULT_ACTIONS.push(CQ.wcm.Sidekick.MY_CONFIG); })(); </script> </c:if>

Don't worry about the "isAuthor" part. We are using a framework that enables that to work, using a bean pattern. Again, this works just fine to add the button to the sidekick unless I have the content finder available. Then it fails (but doesn't error). I'm using CQ5.5, SP2 and I've reproduced this with Google Chrome and Mozilla Firefox.

Has anyone experienced this before? I wondered if this is a bug or a problem with my implementation. Anyone have an idea or a workaround?

Thanks for any help!

1 Accepted Solution

Avatar

Correct answer by
Level 10
3 Replies

Avatar

Level 10

Here is a community article that talks about modifying the sidekick:

http://daycq.blogspot.ca/2012/05/hi-team-have-requirement-where-we-need.html

I hope this helps you. 

Avatar

Correct answer by
Level 10

Avatar

Former Community Member

I'm aware of how to add a button to the sidekick. That wasn't the issue. The issue was that there was a weird inconsistency where my code worked if I had the content finder removed, but did not work if the content finder was there.

I ended up figuring out the solution, though I don't exactly know the root cause...

To make the code more extensible (I customize the sidekick in a number of places), I slightly reimplemented the init.jsp myself. Instead of adding to/using CQ.wcm.Sidekick.DEFAULT_ACTIONS, I created my own JS object, MyApp.wcm.Sidekick.ACTIONS, which gets preloaded with DEFAULT_ACTIONS, plus anything custom I need for the given page. I use this through the entire site.

In my custom init.jsp, I have to specify to use MyApp.wcm.Sidekick.ACTIONS as the list of sidekick actions, obviously so it won't use the defaults. To do so, you use the "actions" property passing in your array of sidekick actions when you call launchSidekick(). I had a typo and specified "action", not "actions" (plural).

What made this particularly tricky was that "action" still kind of worked (it did without the content finder). No JS errors, not issues with the sidekick other than my missing button. I don't know if this is coincidence, some deprecated JavaScript method or if the sidekick just swallows errors and falls back to default behavior. But, in case anyone was curious, this was the solution.