In Chapter 6, Application Domain Layer, we looked at a Lightning Component that can be placed on the Lightning Record Page layout. This approach only applies to Lightning Experience and also provides some additional benefits, such as being able to listen to events Lightning Experience fires as users in-line edit the record details. This approach currently only applies when viewing the record details. The following screenshot is a reminder of what the Compliance Verification component looks like when placed on the standard UI:
Let's now look at an example that shows how to customize the standard UI that applies both to Salesforce Classic and Lightning Experience by embedding a Visualforce page in a detailed Page Layout, as shown in the following screenshot for the Race object. Page Layouts are leveraged in both Salesforce Classic and Lightning Experience.
The following Visualforce page uses the lightningStylesheets attribute to indicate that the page style should automatically reflect the container it is running in, as shown in the following screenshots. It reuses the Extension Controller from the previous chapter:
<apex:page standardController="Race__c"
lightningStylesheets="true"
extensions="RaceSummaryController"
action="{!loadSummary}">
<apex:outputPanel>
<apex:pageBlock>
<apex:pageBlockTable value="{!Summary}"
var="summaryRow">
<apex:column value="{!summaryRow.Position}">
<apex:facet name="header">Position</apex:facet>
</apex:column>
<apex:column value="{!summaryRow.Driver}">
<apex:facet name="header">Driver</apex:facet>
</apex:column>
<apex:column value="{!summaryRow.Team}">
<apex:facet name="header">Team</apex:facet>
</apex:column>
<apex:column value="{!summaryRow.Car}">
<apex:facet name="header">Car</apex:facet>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:page>
As the page uses StandardController, it appears in the layout editor and can be positioned on the layout:
You can then drag and drop it into an existing or new section on the layout. In Lightning Experience, the page looks like the following screenshot:
The result will look something like the following screenshot in Salesforce Classic: