Side kick is the container for all possible components to be used in particular page, edit various properties of the page, versioning and workflows specific to page.
This will be loaded in author,preview,analytic,read only and design modes. If there is a requirement to hide the side kick in particular page or in particular mode we have below options.
Option 1: To hide the side kick in particular mode
We can handle this situation from init file itself as this is common for all the pages. Below scriptlet from init.jsp has to be commnented out.
CQ.WCM.launchSidekick("<%= xssAPI.getValidHref(currentPage.getPath()) %>", { propsDialog: "<%= dlgPath == null ? "" : xssAPI.getValidHref(dlgPath) %>", locked: <%= currentPage.isLocked() %> });
Option 2: To hide side kick for particular page or on particular condition
In order to hide the side kick from the page there are 3 methods.
- hide()
- disable()
- destroy()
hide() will not show the side kick from page whereas disable() will load the side kick and hide the options only. But destroy() will delete the side kick itself on the load.
Below is the Ext JS script to be used in order to hide the side kick from page. side kick class is CQ.wcm.Sidekick and xtype of this is sidekick.
Once DOM loaded (CQ.Ext.onReady), checks the sidekick is ready (CQ.WCM.isSidekickReady()), if so that will be hidden(or disabled or destroyed).
Otherwise an event listener will be triggered on sidekick ready ( CQ.WCM.on(“sidekickready”, fn())), then it will be hidden
Script 1:
This script is used when the content finder is not enabled.
CQ.Ext.onReady(function(){ if (CQ.WCM.isSidekickReady()) { CQ.WCM.getSidekick().hide(); } else { CQ.WCM.on("sidekickready", function(sidekick) { sidekick.hide(); }); } });
Script 2:
If content finder is enabled, this will not work. Reason is there will be a window opened to separate the content finder and the page. So we need to fetch the top window then perform this action
CQ.Ext.onReady(function(){ var top = CQ.WCM.getTopWindow(); if (top.CQ.WCM.isSidekickReady()) { top.CQ.WCM.getSidekick().hide(); } else { top.CQ.WCM.on("sidekickready", function(sidekick) { sidekick.hide(); }); } });
Instead of hiding, it is good to use destroy as this will destroy the side kick widget from page context.
You may also interested in:
SlingPostServlet – AEM building block – Sling Default Servlet
Class Loading in OSGI (what? and How?) Introduction to Sling – CQ5 building block |