1

Can we determine if a custom Lightning Component is placed on Home Page Layout or Record Home Layout or is displayed as a separate Lightning Tab?

I would like my component to be differently sized based on the context, but I'm not able to detect where the component is placed inside the component via code. Can someone help me here? Is there a programatic way to determine Lightning Component's Interface context?

1 Answer 1

1

You can certainly tell whether the component is inside Home Page or on the record page via the below attribute

<aura:attribute name="recordId" type="String" />

or in JS controller

if(component.get("v.recordId")!=null){
  console.log('****inside record page***');
}

If you get the value of the attribute and see a valid recordId then its inside Record Home Page but if you do not see its value and is null then its inside Home Page editor or as a Lightning Tab .

I am still not sure how will you distinguish whether it is inside the Home page or the lightning Tab .

1
  • Yes thanks., I was able to do that, though my usecase involves 3rd case of detecting if it is in its own Lightning Tab, this v.recordId will allow me to detect if it is in record home page or not. Can we detect the container being a Lightning Tab or home page as well?
    – VarunC
    Aug 12, 2016 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .