Search In This Blog

2016-09-21

Use template in Visualforce page

If pages have same part like header or footer, use page template will be more efficient.

Salesforce provides some page template. For example, when you create a community site, Salesforce will create a page template named CommunitiesTemplate.

<apex:page showHeader="false" sidebar="false" id="CommunitiesTemplate">
  <apex:stylesheet value="{!$Site.Prefix}/communities/CommunitiesStyles.css"/>
  <apex:insert name="header"/>
  <apex:insert name="body"/>
  <apex:insert name="footer"/>
</apex:page>

<apex:insert name="header"/> is the header part.
<apex:insert name="body"/> is the main content part.
<apex:insert name="footer"/> is the footer part.

<!-- Import template by id -->
<apex:composition template="CommunitiesTemplate">
       <apex:define name="header">This is header used to contain something like: logo, nav menu...</apex:define>
       <apex:define name="body">This is the body  used to contain contents and sidebar.</apex:define>
       <apex:define name="footer">This is the footer. Usually use to contain copyright.</apex:define>
</apex:composition>

No comments:

Post a Comment