This article is to demonstrate how a small piece of codes allow content authors, on author instance, to turn sidekick on/off. Don't ask me why. I had a case where this was desired. Here's the codes (it's a JSP/JS codes):

Note: don't forget to include: https://github.com/nimsothea/jquery-cookie/blob/master/src/jquery.cookie.js or have/use your own cookie functions.

<script>
<% final QueryStringParser queryStringParser = new QueryStringParser(request.getQueryString()); %> <% if (WCMMode.fromRequest(request) == WCMMode.EDIT) { if (queryStringParser.get("sidekickmode").equals("off")) { out.print("jQuery.cookie('sidekickmode','off',{expires:365,path:'/'});"); } else if (queryStringParser.get("sidekickmode").equals("on")) { out.print("jQuery.cookie('sidekickmode','on',{expires:365,path:'/'});"); } out.print("if(CQ && CQ.WCM && jQuery.cookie('readysidekickmode')==='off'){CQ.WCM.on('editablesready',function(){CQ.WCM.getSidekick().hide();jQuery('#cq-sk').remove();});}"); } %> </script>

Here's the Java codes for parsing Query String (you can use your own):

package com.myproject.util;

/**
 * For parsing URL query string and store in a HashMap<String, String>.
 */

import java.util.HashMap;

public class QueryStringParser {
    
    private String qStr = "";
    private final HashMap<String, String> requestParams = new HashMap<String, String>();
    
    public QueryStringParser(String requestQstr) {
        
        if (requestParams.isEmpty() && requestQstr != null && requestQstr.length() > 0) {
            
            qStr = requestQstr;
            parsing();
        }
    }
    
    public boolean containsKey(String key) { return requestParams.containsKey(key); }
    
    /**
     * @param qName
     * @return str
     */
    public String get(String qName) { return this.get(qName, ""); }
    
    public String get(String qName, String defaultVal) {
        
        return requestParams.containsKey(qName) ? requestParams.get(qName) : defaultVal;
    }
    
    /**
     * Parses string (request.getQueryString()) and store in a HashMap<String, String> requestParams
     */
    private void parsing() {
        
        String[] qStrList = qStr.split("&");
            
        for (String qStrList1 : qStrList)
        {
            String[] pair = qStrList1.split("=");

            if (pair.length == 1)
            {
                requestParams.put(pair[0], "");
            }
            else if (pair.length == 2)
            {
                requestParams.put(pair[0], pair[1]);
            }
        }
    }
}

Finally, in the browser address, just have content authors request:

  • http://<author-hostname>:<port></path/to/a/page.html>?sidekickmode=off to turn the sidekick off.
  • http://<author-hostname>:<port></path/to/a/page.html>?sidekickmode=on to turn the sidekick on.