Newer Version Available
Create Custom Theme Layout Components for Experience Builder
A theme layout component is the top-level layout (1) for the template
pages in your site. Theme layout components are organized and applied to your pages through
theme layouts. A theme layout component includes the common header and footer (2), and often
includes navigation, search, and the user profile menu. In contrast, the content layout (3)
defines the content regions of your pages. The next image shows a two-column content
layout.
A theme layout type categorizes the pages in your Experience Builder site that share the same theme layout.
When you create a custom theme layout component in the Developer Console, it appears in Experience Builder in the area. Here you can assign it to new or existing theme layout types. Then you apply the theme layout type—and thereby the theme layout—in the page’s properties.
1. Add an Interface to Your Theme Layout Component
A theme layout component must implement the forceCommunity:themeLayout interface to appear in Experience Builder in the area.
Explicitly declare {!v.body} in your code to ensure that your theme layout includes the content layout. Add {!v.body} wherever you want the page’s contents to appear within the theme layout.
You can add components to the regions in your markup or leave regions open for users to drag-and-drop components into. Attributes declared as Aura.Component[] and included in your markup are rendered as open regions in the theme layout that users can add components to.
- search, which contains the Search Publisher component
- profileMenu, which contains the User Profile Menu component
- navBar, which contains the Navigation Menu component
2. Add a Design Resource to Include Theme Properties
You can expose theme layout properties in Experience Builder by adding a design resource to your bundle.
This example adds two checkboxes to a theme layout called Small Header.
The design resource only exposes the properties. You must implement the properties in the component.
Design resources must be named componentName.design.
3. Add a CSS Resource to Avoid Overlapping Issues
Add a CSS resource to your bundle to style the theme layout as needed.
- Apply CSS
styles.
- Wrap the elements in your custom theme layout in a div
tag.
CSS resources must be named componentName.css.