You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-to/how-to-add-appearance.md
+20-13Lines changed: 20 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
3
3
Appearances provide different layout and styling options for a content type. For example, the Banner content type has four appearances. Each appearance shows a different layout for the Banner's text and button.
4
4
5
-
This topic shows how to add appearances to existing content types. An overview of the steps and the files you need to add are illustrated here:
5
+
This topic shows how to add appearances to Page Builder's native content types. An overview of the steps and the files you need to add are illustrated here:
6
6
7
7

8
8
9
9
_Steps for adding appearances_
10
10
11
-
Even though this topic describes how to add appearances to Page Builder's native content types, the steps can be applied to adding more appearances to your custom content types as well.
11
+
These steps also apply to adding appearances to your custom content types and third-party content types.
12
12
13
-
## Step 1: Add VisualSelect class
13
+
## Step 1: Add virtual type for VisualSelect class
14
14
15
15
First, we need a way select an appearance within the Admin UI. In Page Builder, we use the `VisualSelect` class. This class provides the UI for selecting different appearances. For example, the `VisualSelect` class for the Banner provides four appearances to choose from:
16
16
@@ -24,15 +24,14 @@ To add a new appearance option for one of Page Builder's native content types, l
24
24
25
25
_File and location for the VisualSelect class_
26
26
27
-
Within the `di.xml` file, add a `VisualSelect` class using the Banner's `VisualSelect` class name (`<virtualType name="AppearanceSourceBanner"`), as shown here:
27
+
Within the `di.xml` file, add a virtual type using the`VisualSelect` class with the Banner's virtual type name (`<virtualType name="AppearanceSourceBanner"`), as shown here:
|`optionsSize`| The size of the icons that display each option. Use `large` for appearance options. |
54
52
|`optionsData`| Grouping array for all the appearance options of a content type. |
55
53
|`item array`| Grouping array of properties that define an appearance option. The `name="4"` signifies the index order for displaying the option. The Banner's existing options stop with an index of 3 (`name="3"`), ensuring that our new appearance option is positioned after the last Banner option. |
56
54
|`value`| Assigns the unique key used in the component dataSource. |
@@ -59,15 +57,15 @@ The following table describes the configuration arguments for each appearance op
59
57
|`noticeMessage`| (Not shown in example.) The `noticeMessage` displays a message below the appearance options when the appearance is selected. For example, two of the Row appearances (`full-width` and `full-bleed`) define `noticeMessage` strings that display when selected. |
60
58
{:style="table-layout:auto"}
61
59
62
-
To add more appearance options, simply create more `item` arrays, as shown here:
60
+
To add more appearance options, simply create more `item` arrays, as shown here:
@@ -167,6 +165,15 @@ _Additional simple-poster appearance for the Banner content type_
167
165
168
166
Appearances for a content type can share the same form or use different forms. For example, the Products content type uses two different forms, one for each appearance. The Grid appearance uses the `pagebuilder_products_form.xml` to provide options for displaying products in a grid. While the Carousel appearance uses the `pagebuilder_products_carousel_form.xml` to provide extra options for displaying products in a carousel.
169
167
168
+
When you select an appearance with its own form, Page Builder replaces the content type's form (defined in the `<type>` element) with the appearance's form. But when you select an appearance that does not have a form defined, the appearance switches back to using the content type's form.
_Content type form used by default for all appearances_
176
+
170
177
To add a form for an appearance, add a `<form>` element as a child of the `<appearance>` element in your content type's config file. As mentioned, the Products content type does this for its Carousel appearance, shown here:
171
178
172
179
```xml
@@ -182,15 +189,15 @@ _Adding a form to an appearance_
182
189
183
190
## Step 4: Add appearance templates
184
191
185
-
Appearances use different HTML templates to create different layouts and apply different styles to those layouts. For example, the Banner content type uses four sets of `preview.html` and `master.html` templates, to create the visual differences for each content type:
192
+
Appearances use different HTML templates to create different layouts and apply different styles to those layouts. For example, the Banner content type uses four sets of `preview.html` and `master.html` templates to create the visual differences for each content type:
Each template set is located within a folder named after the appearance for which they are used. The folder names must match the appearance names assigned in the content type's config file.
198
+
Notice how Page Builder organizes the Banner templates by appearance name. We recommend the same practice when adding templates for your appearances.
192
199
193
-
To create appearance templates for additional Banner appearances, such as the `simple-poster` appearance described in steps 1 and 2, you must add a new appearance folder for your module's templates, as shown here:
200
+
To create appearance templates for additional Banner appearances, such as the `simple-poster` appearance described in steps 1 and 2, add a new appearance folder for your module's templates, as shown here:
0 commit comments