To check if the Lightning component is in Lightning Community Page or in Salesforce Lightning CRM page, we can make use of Site Class‘s method – getSiteType().
this return these values
Create an @AuraEnabled method in Apex Controller:
@AuraEnabled
public static String getSiteType() {
return Site.getSiteType();
controller to fetch
var communityPageKeys = ['ChatterNetwork', 'ChatterNetworkPicasso'];
var action = component.get("c.getSiteType");
action.setCallback(this, function (response) {
if (response.getState() === "SUCCESS") {
if (communityPageKeys.indexOf(response.getReturnValue()) < 0) {
// This is not a community page
} else {
// This is a community page
}
}
});
$A.enqueueAction(action);
Reference [https://vijayasankarn.wordpress.com/2018/02/12/lightning-component-is-it-in-community-or-in-lightning-page/]
Top comments (0)