AEM CQ 56 - Get Sidekick instance and disable components panel

Goal


In your javascript code of a component, get the sidekick (CQ.wcm.Sidekick) instance and disable components panel

Often situations arise where you need to play with the sidekick of AEM (CQ5) instance and do some customization. This is not Adobe recommended or suggested approach. It's just a way to get the sidekick and do operations on sidekick components.

Tested on 


Adobe Experience Manager ( AEM 561 )

Solution - 1


1) Login to CRXDE Lite (http://localhost:4502/crx/de) and create folder /apps/sk-comp-panel-disabled

2) Create node /apps/sk-comp-panel-disabled/clientlib of type cq:ClientLibraryFolder and add a String property categories with value cq.widgets

3) Create file (nt:file) /apps/sk-comp-panel-disabled/clientlib/js.txt and add

                       disabled.js

4) Create file (nt:file) /apps/sk-comp-panel-disabled/clientlib/disabled.js and add the following code

(function(){
    if( ( window.location.pathname == "/cf" ) || ( window.location.pathname.indexOf("/content") == 0)){
        CQ.WCM.on("sidekickready", function(sk){
            sk.on("loadcontent", function(){
                var compTab = sk.panels["COMPONENTS"];

                if (compTab) {
                    compTab.setDisabled(true);
                }
            });
        });
    }
})();

Solution - 2


In your component jsp add the following script

<script type="text/javascript">
    window.MyComponent = window.MyComponent || {};

    MyComponent.HideComponentsPanel = {
        IN_ID : '',

        disableFn: function(){
            try{
                var sk = CQ.WCM.getSidekick();

                if(!sk){
                    return;
                }

                var compTab = sk.panels["COMPONENTS"];

                if (compTab) {
                    compTab.setDisabled(true);
                    clearInterval(MyComponent.HideComponentsPanel.IN_ID);
                }
            }catch(err){
                console.log("Error:--" + err);
            }
        }
    }

    CQ.Ext.onReady(function(){
        var h = MyComponent.HideComponentsPanel;
        h.IN_ID = setInterval(h.disableFn, 500);
    });
</script>


5 comments:

  1. Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.I get a lot of great information from this blog. Thank you for your sharing this informative blog.Adobe CQ5 Training | Adobe CQ5 Online Training

    ReplyDelete
  2. can any one explain me about i18n.and how it works in adobe cq

    ReplyDelete
  3. One of the biggest challenges that organizations face today is having inaccurate data and being unresponsive to the needs of the Adobe CQ5 CMS Email List organization.

    ReplyDelete