Lightning Component for Custom Lightning Templates
Lightning App Builder provides flexibility to create custom Lightning pages which can be used in opposite of standard Lightning pages. Even though every standard Lightning page is associated with a default template component, Custom Lightning page template components are useful when you want a customized template for your business needs.
Custom Lightning pages can be created for.....
In order to create custom Lightning Templates for App/Home/Record pages, it is required to implement below interface for each.
Note** Each template component should implement only ONE template interface. Template components shouldn’t implement any other type of interface, such as flexipage:availableForAllPageTypes or force:hasRecordId. A template component can’t multi-task as a regular Lightning component. It’s either a template, or it’s not.
Below is a sample custom Lightning page template component (Component and Design Resources) for Home page that implements "lightning:homeTemplate" interface, which will further expose the custom component in Lightning App Builder for creating custom Lightning page. Here "TempHome.design" resource controls what kind of page can be built on the template by specifying what regions a page that uses the template must have and what kinds of components can be put into those regions.
TempHome.cmp
<aura:component implements="lightning:homeTemplate" description="Custom Template for the Home Page"> <aura:attribute name="cmp1" type="Aura.Component[]" /> <aura:attribute name="cmp2" type="Aura.Component[]" /> <aura:attribute name="cmp3" type="Aura.Component[]" /> <div> <lightning:layout horizontalAlign="spread"> <lightning:layoutItem size="4"> {!v.cmp1} </lightning:layoutItem> <lightning:layoutItem size="4"> {!v.cmp2} </lightning:layoutItem> <lightning:layoutItem size="4"> {!v.cmp3} </lightning:layoutItem> </lightning:layout> </div> </aura:component>
TempHome.design
<design:component label="Custom Home Page Template"> <flexipage:template > <flexipage:region name="cmp1" defaultWidth="Xlarge" /> <flexipage:region name="cmp2" defaultWidth="Xlarge" /> <flexipage:region name="cmp3" defaultWidth="Xlarge" /> </flexipage:template> </design:component>
Now once I have created above component, I should be able to create a new Lightning page for my Home page using above custom component Lightning template. Similarly we can create component templates for App and Record pages just by replacing interface to "lightning:appHomeTemplate" and "lightning:recordHomeTemplate" respectively.
Best Practices to use Lightning Page Template Component:
Resource Links:
Can we create Subtabs for the App Page Template and put different components in each tab. I Created the skeleton for subtabs. but in the app builder I am not able to move to other subtabs for putting different components
ReplyDeleteReally Informative
ReplyDeleteRead How Salesforce Lightning Increases Productivity
Great job. If you want to know more about templates you should visit this site where there are many different categories including dentistry website templates
ReplyDeleteCan we create pinned regions in custom templates for console app ?
ReplyDeleteNice article!
ReplyDeleteI found many useful information in your blog, it was awesome to read,thanks for sharing this great content, keep sharing..
Custom Lightning Lead Conversion W/O Opportunity
Thanks for such wonderful article.
ReplyDeleteIs it possible to use server side controller with lightning:recordHomeTemplate. I have a use case where I want to store some details on user click.
I tried but not able to connect server side apex method. Dint find any documentation regarding the same.