We want to fetch wcmmode value in our custom Javascript file, based on mode some condition needs to be executed. Can you please let us know ways to fetch those.
If wordpress is blocked by anyone else's corporate proxy (like ours), here's the core of that article:
/* * EditMode.js * * Simple javascript object meant to be used within a CQ development to understand on a Javascript side which my Edit Mode is. * * USAGE: * 1) Drop the file in your clientlib * 2) Reference it in your js.txt * * You can now use it as it will automatically create an "editmode" object * (editmode.isEditMode()) ? "I'm Authoring" : "" * (editmode.isPreviewMode()) ? "I'm in Preview" : "" * (editmode.isDesignMode()) ? "I'm in Design" : "" * (editmode.isDisabled()) ? "I'm in Disabled" : "" */ function EditMode(){ this.isEditMode=function(){ return (CQ.WCM)?CQ.WCM.isEditMode(true):false; }; this.isPreviewMode=function(){ return (CQ.WCM)?CQ.WCM.isPreviewMode(true):false; }; this.isDesignMode=function(){ return (CQ.WCM)?CQ.WCM.isDesignMode(true):false; }; this.isDisabled=function(){ return (!CQ.WCM); } }; var editmode = new EditMode();
See this community article- http://labs.6dglobal.com/blog/2013-04-02/what-my-cq-mode/ . The CQ.WCM object provides methods for checking the current mode, however first you need to see if the object exists. CQ.WCM is not instantiated in publish mode, so it will return null in publish mode.