banner



How To Change Home Page Template In Salesforce Lighning

Have you ever wished for a new layout for your habitation page? How almost more than command over the columns on your record page? With the custom Lightning page template feature and a little bit of code, you can go manner across the out of the box templates. This weblog post is going to help yous get started with your ain templates and so we will swoop into some absurd things you can do!

What is a Lightning folio template anyway?

Lightning page templates are components that define a page's regions and tin be used for Home, Record or App pages. Both standard and custom templates appear in the App Builder'due south New Folio Wizard and can exist used to create new pages for an app. They are pretty easy to create, so let's dive in!

Getting started

In that location are a few things you need to exist aware of when building a new Lightning page template. The almost important thing is to decide where you want your template to be used. You must specify if you want it available on an App, Home or Tape page. You have to pick only 1, since you lot can't use more than than one interface.

The side by side thing to be aware of the .svg file, which is an image type. This file works differently for Lightning page templates than Lightning components. For a component, an .svg would testify upward in the left-mitt bar of the Lightning App Builder. For a Lightning page template, it shows up on the screen where you select which template you want to employ. No matter what you do, your custom templates will appear in the new page magician, merely if you lot leave the .svg alone, information technology will be hard to distinguish your templates from each other. Yous can add an .svg file to provide App Builder users with an image preview of the template.


The black box here identifies where the .svg will appear.

Exactly what your users asked for: A Abode Page with three regions

Nosotros've but received a request for an amazing custom Lightning page template in our org. Our offset stride is to dream about what kind of page we would like. Permit'south imagine that your users have requested a Home page with three columns. It's a pretty standard enquire with a simple look and feel, but yous draw information technology upwards anyhow, just to be sure.

Next, we are going to create a brand new Lightning component. Then we tin can remember, nosotros've called information technology ThreeRegionHome (and so creative, right?). We've got to make sure we implement the correct interface for a Dwelling house page and we add a description, because nosotros are great developers. Since we know we but need three regions and they are going to be columns, we create some attributes for those. Then far our component looks like this:

ThreeRegionHome.cmp

<aura:component implements="lightning:homeTemplate"                  description="A home page you lot ever dreamed of, 3 columns." >     <aura:attribute name="column1" type="Aura.Component[]" />     <aura:attribute proper name="column2" blazon="Aureola.Component[]" />     <aura:attribute name="column3" type="Aura.Component[]" /> </aureola:component>

It is pretty simple but it doesn't do anything yet — it won't even bear witness upward in the Lightning App Builder! Oh no! Thankfully the fix is pretty piece of cake — we just have to write our design file. The label in our design file is the label that volition show up in the Lightning App Architect, so nosotros make sure it is something yous and your admins volition sympathise.

ThreeRegionHome.design

<design:component label="3 Cavalcade Page">     <flexipage:template >       <flexipage:region name="column1" defaultWidth="Medium" />       <flexipage:region name="column2" defaultWidth="Medium" />       <flexipage:region name="column3" defaultWidth="Medium" />   </flexipage:template> </blueprint:component>

At present our page shows upwards in Lightning App Builder, but we don't run into any place to add components to our columns. This is because all we've done and then far is say there will exist attributes, but we oasis't told the folio what it should look like. This is when we start leveraging lightning:layout and lightning:layoutItem.

ThreeRegionHome.cmp

<aura:component implements="lightning:homeTemplate"                  description="A dwelling page you ever dreamed of, three columns." >     <aureola:attribute name="column1" type="Aura.Component[]" />     <aura:attribute name="column2" type="Aura.Component[]" />     <aureola:aspect name="column3" type="Aura.Component[]" />          <div>         <lightning:layout horizontalAlign="spread" pullToBoundary="small">             <lightning:layoutItem size="4" flexibility="grow"                                    padding="effectually-small">                 {!v.column1}             </lightning:layoutItem>             <lightning:layoutItem size="4" flexibility="grow"                                    padding="around-small">                          {!5.column2}             </lightning:layoutItem>             <lightning:layoutItem size="iv" flexibility="grow"                                    padding="around-small">                 {!v.column3}             </lightning:layoutItem>         </lightning:layout>     </div>  </aura:component>

We can go along working on this page by doing a few other custom things, the virtually important of which is creating the .svg file. You can create an .svg for your folio with tools like Photoshop, Sketch or any other design creation tool. In one case we've created that .svg file and added information technology as ThreeRegionHome.svg we have completed the template.

Now y'all can utilise it in activity! In Lightning App Architect we can create a new home page (or edit an old home folio) and have information technology leverage our fancy new template.

Making a Record folio with collapsing regions

Our users have fallen in love with the new home page and already have brilliant ideas about other kinds of record pages that they would beloved.

Moving picture this scenario: You lot gear up up a whiteboarding session and everyone agreed on a make new blueprint. Information technology'due south a simple folio, merely it volition allow users to collapse and expand an expanse on the right side of a tape page.


This is the new svg your users defined.

Just like before, yous start with your astonishing component file and you swoop right into the nitty gritty. But WHOA, your users requested that some regions collapse, and you've never washed that earlier!

Let's take a quick look at the component code to practice this.

<aureola:component implements="lightning:recordHomeTemplate" description="Full-width header above a main column and collapsible correct sidebar.">      <aura:attribute name="header" blazon="Aura.Component[]" description="Header region"/>     <aureola:aspect proper name="main" type="Aura.Component[]" clarification="Main region"/>     <aura:attribute proper name="sidebar" type="Aura.Component[]" description="Collapsible sidebar region"/>      <aureola:attribute name="isSidebarCollapsed" type="Boolean" admission="PRIVATE" default="faux" />      <div>         <div>{!v.header}</div>         <lightning:layout>             <lightning:layoutItem flexibility="auto">                 {!5.primary}             </lightning:layoutItem>             <lightning:layoutItem flexibility="no-flex">                 <lightning:buttonIcon onclick ="{!c.toggleSection}"                                                                             variant="border-filled"                                       iconName="{! five.isSidebarCollapsed ? 'utility:chevronleft' : 'utility:chevronright' }"                                        alternativeText="{! v.isSidebarCollapsed ? 'Expand Sidebar' : 'Collapse Sidebar' }" />             </lightning:layoutItem>             <lightning:layoutItem size="four">                 {!five.sidebar}             </lightning:layoutItem>         </lightning:layout>     </div> </aura:component>

However, it won't work until nosotros write a uncomplicated Javascript method to toggle what is open up. It turns out to be pretty elementary!

({     toggleSection : function(component, upshot, helper) {         component.set('v.isSidebarCollapsed', !component.become('v.isSidebarCollapsed'));     } })

Of form, nosotros can't forget our design file. You'll notice that we decided to make our columns and the left and right smaller than the middle column.

<design:component label="Header and Collapsible Right Sidebar">     <flexipage:template>         <flexipage:region name="header" defaultWidth="Big" />         <flexipage:region name="master" defaultWidth="MEDIUM" />         <flexipage:region name="sidebar" defaultWidth="SMALL" />     </flexipage:template> </design:component>

Finally, we add our custom .svg and it's off to the races to update our tape pages to our new layout!

<?xml version="1.0" encoding="UTF-viii"?> <svg version="1.ane" viewBox="0 0 565 153" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Full-width header higher up a main cavalcade and collapsible right sidebar.</title> <desc>Created with Sketch.</desc> <defs> <path id="d" d="m52.919 23.328c1.0531 1.6487 vii.4332 2.9429 7.4332 2.9429s1.6838 i.2352-4.5419 1.2352c-4.383-ane.2e-6 -17.873-7e-7 -25.475-3e-vii -seven.6019-4e-vii -21.092-9e-7 -25.475 3e-7 -6.2257 2.5e-vi -4.5419-1.2352-four.5419-ane.2352s6.3801-1.2942 7.4332-two.9429c1.0531-1.6487 ii.8854-23.259 2.8854-23.259h39.397s1.8324 21.61 2.8854 23.259z"/> <rect id="b" y=".48418" width="200" height="123.57" rx="three.8554"/> <path id="c" d="m52.919 23.328c1.0531 one.6487 seven.4332 2.9429 vii.4332 2.9429s1.6838 1.2352-4.5419 one.2352c-4.383-i.2e-half dozen -17.873-7e-7 -25.475-3e-vii -7.6019-4e-7 -21.092-9e-7 -25.475 3e-7 -6.2257 ii.5e-vi -4.5419-1.2352-4.5419-1.2352s6.3801-1.2942 7.4332-two.9429c1.0531-1.6487 2.8854-23.259 2.8854-23.259h39.397s1.8324 21.61 2.8854 23.259z"/> <rect id="a" y=".48418" width="200" superlative="123.57" rx="3.8554"/> </defs> <k fill="none" fill-rule="evenodd"> <k transform="translate(-1 -64)"> <g transform="translate(58 63)"> <g transform="interpret(69.half-dozen 124.02)"> <path d="m60.555 26.901v0.77015c0.064783 0.36534-0.49884 0.94111-iv.749 0.94111-4.3826-1.2e-6 -17.872-7e-7 -25.473-3e-7 -7.6013-4e-7 -21.091-9e-7 -25.473 3e-seven -4.2501 1.7e-6 -4.8138-0.57576-4.7436-0.94111l-0.005392-0.77015 0.75324 0.33579h58.938l0.75324-0.33579z" opacity=".5"/> <path d="m60.555 26.565v0.77015c0.064783 0.36534-0.49884 0.94111-4.749 0.94111-four.3826-i.3e-6 -17.872-8e-seven -25.473-4e-7 -vii.6013-4e-seven -21.091-9e-seven -25.473 4e-7 -4.2501 ane.6e-6 -4.8138-0.57576-4.7436-0.94111l-0.005392-0.77015 0.75324 0.33579h58.938l0.75324-0.33579z" fill="#C6C7CA"/> <mask fill up="white"> <apply xlink:href="#d"/> </mask> <use fill="#D8D8D8" xlink:href="#d"/> </g> <g transform="translate(0 .48418)"> <mask id="f" make full="white"> <use xlink:href="#b"/> </mask> <use fill="#9B9B9B" fill-opacity=".30016" xlink:href="#b"/> <use make full="#E1E1E1" xlink:href="#b"/> <g fill="#fff" mask="url(#f)"> <g transform="interpret(six.747 ix.1994)"> <rect width="186.54" elevation="104.25"/> </g> </k> </g> <g transform="translate(6.9156 9.3421)"> <rect y=".32109" width="186.35" height="20.132" make full="#54698D"/> <rect 10="four.8193" y="24.963" width="130.36" summit="74.024" fill="#54698D"/> <rect x="140.56" y="24.963" width="xl.562" height="74.024" fill="#54698D"/> <rect x="135" y="25" width="8" height="74.024" make full="#9FAAB5"/> </thou> <g transform="translate(249)"> <g transform="translate(69.6 124.02)"> <path d="m60.555 26.901v0.77015c0.064783 0.36534-0.49884 0.94111-4.749 0.94111-4.3826-1.2e-6 -17.872-7e-vii -25.473-3e-vii -7.6013-4e-seven -21.091-9e-seven -25.473 3e-7 -4.2501 1.7e-half dozen -4.8138-0.57576-iv.7436-0.94111l-0.005392-0.77015 0.75324 0.33579h58.938l0.75324-0.33579z" opacity=".5"/> <path d="m60.555 26.565v0.77015c0.064783 0.36534-0.49884 0.94111-four.749 0.94111-4.3826-1.3e-half dozen -17.872-8e-7 -25.473-4e-7 -7.6013-4e-vii -21.091-9e-7 -25.473 4e-seven -4.2501 1.6e-vi -4.8138-0.57576-iv.7436-0.94111l-0.005392-0.77015 0.75324 0.33579h58.938l0.75324-0.33579z" fill="#C6C7CA"/> <mask fill="white"> <employ xlink:href="#c"/> </mask> <use fill="#D8D8D8" xlink:href="#c"/> </k> <g transform="interpret(0 .48418)"> <mask id="east" fill up="white"> <use xlink:href="#a"/> </mask> <use fill up="#9B9B9B" fill up-opacity=".30016" xlink:href="#a"/> <use fill="#E1E1E1" xlink:href="#a"/> <g make full="#fff" mask="url(#eastward)"> <g transform="interpret(half-dozen.747 9.1994)"> <rect width="186.54" height="104.25"/> </g> </thou> </one thousand> <k transform="interpret(6.9156 9.3421)"> <rect y=".32109" width="186.35" height="xx.132" fill="#54698D"/> <rect ten="4.8193" y="24.963" width="175.18" elevation="74.024" fill="#54698D"/> <g transform="translate(178.28 24.998)"> <rect x=".084426" y="-2.8422e-fourteen" width="8" acme="74.024" fill="#9FAAB5"/> <path transform="translate(3.v 38.014) rotate(180) interpret(-iii.v -38.014)" d="m5.1056 38.461l-3.382 i.691c-0.24699 0.12349-0.54733 0.023382-0.67082-0.22361-0.034714-0.069428-0.052786-0.14598-0.052786-0.22361v-3.382c0-0.27614 0.22386-0.5 0.v-0.v 0.077623 0 0.15418 0.018073 0.22361 0.052786l3.382 ane.691c0.24699 0.12349 0.3471 0.42383 0.22361 0.67082-0.048382 0.096764-0.12684 0.17522-0.22361 0.22361z" fill="#fff"/> </g> </g> </g> </g> <path d="m205.52 135.8l-3.382 1.691c-0.24699 0.12349-0.54733 0.023382-0.67082-0.22361-0.034714-0.069428-0.052787-0.14598-0.052787-0.22361v-3.382c0-0.27614 0.22386-0.v 0.5-0.5 0.077623 0 0.15418 0.018073 0.22361 0.052787l3.382 1.691c0.24699 0.12349 0.3471 0.42383 0.22361 0.67082-0.048382 0.096764-0.12684 0.17522-0.22361 0.22361z" fill="#fff"/> </thousand> </one thousand> </svg>

Pulling it all together

Now that you've seen a few actually snazzy means to make a Custom Lightning Page Template, you can cheque out even more examples on Github or download them into your own org through the Salesforce App Commutation. We besides encourage anybody to dive in and make your own! Share your custom template with u.s.a. on Twitter and tell united states well-nigh your amazing use cases.

Heather Dykstra
Programmer Evangelist, Salesforce
@SlytherinChika

Additional resources

  • Lightning Page Template Component Best Practices
  • Related Trailhead Module: Lightning App Builder
  • Lightning Blueprint System Documentation

Stay upwards to engagement with the latest news from the Salesforce Developers Web log

Subscribe

How To Change Home Page Template In Salesforce Lighning,

Source: https://developer.salesforce.com/blogs/2018/08/all-about-custom-lightning-page-templates

Posted by: tomczaksayint.blogspot.com

0 Response to "How To Change Home Page Template In Salesforce Lighning"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel