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
+12-3Lines changed: 12 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Appearances provide different layout and styling options for a content type. For
5
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:
6
6
7
7

8
+
8
9
_Steps for adding appearances_
9
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.
@@ -14,11 +15,13 @@ Even though this topic describes how to add appearances to Page Builder's native
14
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:
To add a new appearance option for one of Page Builder's native content types, like the Banner, create a new `di.xml` file in your module, as shown here:
Within the `di.xml` file, add a `VisualSelect` class using the Banner's `VisualSelect` class name (`<virtualType name="AppearanceSourceBanner"`), as shown here:
@@ -54,6 +57,7 @@ The following table describes the configuration arguments for each appearance op
54
57
|`title`| Display name for the appearance option. Banner example: Poster. |
55
58
|`icon`| Path to the `.svg` icon for the appearance: `view/adminthtml/web/css/images/content-type/[content-type-name]/appearance/*.svg`. See Creating an icon for your appearance |
56
59
|`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
+
{:style="table-layout:auto"}
57
61
58
62
To add more appearance options, simply create more ` item` arrays, as shown here:
59
63
@@ -101,19 +105,22 @@ You can use whatever tool you want to create your SVG. Just make sure you follow
101
105
| background `rect y`| 21 |
102
106
| background `rect fill`| #524D49 |
103
107
| other `rect fill` properties | #FFF |
108
+
{:style="table-layout:fixed"}
104
109
105
110
## Step 2: Add appearance configurations
106
111
107
112
Appearance configurations connect the data entered in a content type's form to its HTML templates. For example, the Heading content type has an `<html>` config element (`<html name="heading_text" />`) that maps the text entered into the content type's `heading_text` form field (`<field name="heading_text" formElement="input">`) to the Heading's Knockout template binding (`html="data.main.html"`), as illustrated here:
The same concept applies to `styles`, `attributes`, and `css` elements. These elements ensure that the form settings (both content and styles) get applied to the templates as expected.
113
119
114
120
To add a new Banner appearance configuration, create a content type config file named `banner.xml`, as shown here:
_Add additional appearances to Banner content type_
118
125
119
126
{: .bs-callout .bs-callout-info }
@@ -171,25 +178,29 @@ _Adding a form to an appearance_
171
178
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.
177
185
178
186
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:
Appearances use different CSS/LESS files to create different visual styles for a content type. For example, the Banner content type uses a different `.less` file for each appearance, as shown here:
To create a LESS stylesheet for an additional Banner appearances, such as the `simple-poster`, you must add a new appearance folder for your module's templates, as shown here:
The `_module.less` file is an import file that ensures the additional stylesheet gets added to the existing Banner styles. The `_module.xml` file for our `simple-poster.less` file looks like this:
@@ -205,6 +216,4 @@ Using appearances to extend Page Builder's native content types represents one o
205
216
206
217
## Example Module
207
218
208
-
An example module for this topic is available for download in the `pagebuilder-examples` repository here:
An example module for this topic is available for download in the [pagebuilder-examples repository](https://github.com/magento-devdocs/pagebuilder-examples/tree/master/Example/PageBuilderBannerAppearance).
0 commit comments