Search This Blog

Thursday 23 March 2017

Switching between layers/WCMModes


In touch UI they are called layers and not modes.

Currently available layers:
- "Edit"
- "Preview"
- "Annotate"
- "Developer"
- "Targeting"


Event that captures switching between layers.

cq-layer-activated

A layer has been activated

Type: object

Properties:

Name 

Type 

Description

layer  string  Name of the layer activated
prevLayer  string  Name of the previous layer




Example implementation



$(document).on("cq-layer-activated", function (event) {

var previousLayer = event["prevLayer"];

console.log('previousLayer = ' + previousLayer);

var prevLayer = event.prevLayer;

console.log('prevLayer = ' + prevLayer);

var currentLayer = event["layer"];

console.log('currentLayer = ' + currentLayer);

var curLayer = event.layer;

console.log('curLayer = ' + curLayer);

});


For more information about WCM modes


http://aemconcepts.blogspot.com/2017/03/wcmmodes-aem.html



WCMModes Touch UI

JAVA WCMMODES 


    /** @return true if we are in edit mode, otherwise false */
    public final boolean isEditMode() {
        return WCMMode.fromRequest(getRequest()) == WCMMode.EDIT;
    }

    /** @return true if we are in preview mode, otherwise false */
    public final boolean isPreviewMode() {
        return WCMMode.fromRequest(getRequest()) == WCMMode.PREVIEW;
    }

    /** @return true if we are in publish mode, otherwise false */
    public final boolean isPublishMode() {
        return WCMMode.fromRequest(getRequest()) == WCMMode.DISABLED;
    }

    /** @return true if we are in design mode, otherwise false */
    protected final boolean isDesignMode() {
        return WCMMode.fromRequest(getRequest()) == WCMMode.DESIGN;
    }


JS WCMMODES 


function CustomWCMMode() {
this.isPublish = function() {
return (!ContextHub.Utils.Cookie.exists('wcmmode'));
}
this.isEditMode = function() {
return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'edit');
}
this.isPreviewMode = function() {
return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'preview');
}
this.isDesignMode = function() {
return (ContextHub.Utils.Cookie.getItem('wcmmode') === 'design');
}
};

var customWcmMode = new CustomWCMMode();


SIGHTLY WCMMODES


Publish : ${wcmmode.disabled}

Edit : ${wcmmode.edit}

Design : ${wcmmode.design}

Preview : ${wcmmode.preview}


Switch to preview to edit mode or vice versa by url


url?wcmmode=edit/preview/disabled


How to identify Switching between different WCM mode/layers in touch UI

http://aemconcepts.blogspot.in/2017/03/switching-between-layerswcmmodes.html

Sunday 19 March 2017

Uncaught Error: Components could not be loaded






Its because of the too many client side calls. Increase the "Number of Calls per Request" in sling mail servlet.

Sling main servlet is main processor of the Sling framework controlling all aspects of processing requests inside of Sling, namely authentication, resource resolution, servlet/script resolution and execution of servlets and scripts.


Defines the maximum number of Servlet and Script calls while processing a single client request. The default value is 1000. (sling.max.calls).