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-19Lines changed: 20 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# How to add an appearance
2
2
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.
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 included text and button.
4
4
5
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
@@ -18,7 +18,7 @@ First, we need a way select an appearance within the Admin UI. In Page Builder,
18
18
19
19
_Visual selector for Banner_
20
20
21
-
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:
21
+
To add a new appearance option for one of Page Builder's native content types (such as the Banner), create a new `di.xml` file in your module, as shown here:
|`optionsData`| Grouping array for all the appearance options of a content type. |
53
53
|`item array`| Grouping array of properties that define an appearance option. We recommend you match the `name` of the item array to the option's `value` string. In our example, the `item` array's name is `simple-poster`, which matches the option's value string `simple-poster`. |
54
-
|`value`|The `value` string should match the appearance name defined in the content type's configuration file. Page Builder uses this value to link the option to the appearance.|
54
+
|`value`|String that matches the appearance name defined in the content type's configuration file. Page Builder uses this string value to link the option to the appearance.|
55
55
|`title`| Display name for the appearance option. Banner example: Poster. |
56
56
|`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](#create-an-appearance-icon)|
57
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. |
@@ -75,11 +75,11 @@ _Example of additional appearance options_
75
75
76
76
### Create an appearance icon
77
77
78
-
Appearance icons are `.svg` files that graphically depict the layout of an appearance. Add all the appearance icons for your content type within the following directory: `css/images/content-type/[content-type-name]/appearance/`.
78
+
Appearance icons are `.svg` files that graphically depict the layout of an appearance. Add your additional appearance icons to your module's css appearance directory (`css/images/content-type/[content-type-name]/appearance/`). Additional appearance icons for the Banner would be added as shown here:
You can use any design tool to create your SVG. But if you want to match your appearance icons to Page Builder's icons _perfectly_, use the SVG structure and dimensions shown here:
85
85
@@ -96,7 +96,7 @@ You can use any design tool to create your SVG. But if you want to match your ap
96
96
```
97
97
_SVG appearance template_
98
98
99
-
These specific dimensions ensure that your icon fits seamlessly with the existing appearance icons:
99
+
These specific dimensions ensure that your icon fits seamlessly with Page Builder's existing appearance icons:
100
100
101
101
| Property | Value |
102
102
| ------------------------------ | ----------- |
@@ -114,7 +114,7 @@ These specific dimensions ensure that your icon fits seamlessly with the existin
114
114
115
115
## Step 2: Add appearance configurations
116
116
117
-
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:
117
+
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` field (`<field name="heading_text" formElement="input">`) to the Heading's Knockout template binding (`html="data.main.html"`), as illustrated here:
@@ -129,7 +129,7 @@ To add a new Banner appearance configuration, create a content type config file
129
129
_Add additional appearances to Banner content type_
130
130
131
131
{: .bs-callout .bs-callout-info }
132
-
This procedure applies to any native content type you want to extend. In other words, you can use the file name (`heading.xml`) and type name (`<type name="heading">`) of any native Page Builder content type to extend it based on Magento's XML merging behavior.
132
+
This procedure applies to any native content type you want to extend. In other words, you can use the file name (such as `heading.xml`) and type name (such as `<type name="heading">`) of any content type to extend it based on Magento's XML merging behavior.
133
133
134
134
An example `banner.xml` config file for a new `simple-poster` appearance is shown here:
135
135
@@ -165,7 +165,7 @@ _Additional simple-poster appearance for the Banner content type_
165
165
166
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.
167
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.
168
+
When you select an appearance with a 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.
@@ -174,7 +174,7 @@ When you select an appearance with its own form, Page Builder replaces the conte
174
174
```
175
175
_Content type form used by default for all appearances_
176
176
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:
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 uses a form for its Carousel appearance, as shown here:
178
178
179
179
```xml
180
180
<appearancename="carousel"
@@ -189,19 +189,20 @@ _Adding a form to an appearance_
189
189
190
190
## Step 4: Add appearance templates
191
191
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:
192
+
Appearances use different HTML templates to create different layouts. They also use templates to apply different styles to the same layouts. For example, the Banner uses four sets of `preview.html` and `master.html` templates, one set for each appearance:
Notice how Page Builder organizes the Banner templates by appearance name. We recommend the same practice when adding templates for your appearances.
199
200
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:
201
+
To create templates for additional Banner appearances, such as the `simple-poster` described in steps 1 and 2, add a new appearance folder with your `master.html` and `preview.html` templates, as shown here:
_Add additional templates to `template/content-type/[content-type-name]/[appearance-name]`_
205
206
206
207
## Step 5: Add appearance styles
207
208
@@ -211,11 +212,11 @@ Appearances use different CSS/LESS files to create different visual styles for a
211
212
212
213
_Banner stylesheets_
213
214
214
-
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:
215
+
To create a stylesheet for an additional Banner appearance, such as the `simple-poster`, add a folder named `banner` and a `.less` file with the name of the appearance, as shown here:
_Add additional stylesheets to `css/source/content-type/[content-type-name]/`_
219
220
220
221
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:
221
222
@@ -224,10 +225,10 @@ The `_module.less` file is an import file that ensures the additional stylesheet
224
225
```
225
226
_Use _module.less for import statements_
226
227
227
-
## Conclusion
228
-
229
-
Using appearances to extend Page Builder's native content types represents one of Page Builder's best practices for creating a variety of new content building blocks based on existing content types. We hope this topic has helped adequately describe this best practice.
230
-
231
228
## Example Module
232
229
233
230
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).
231
+
232
+
## Conclusion
233
+
234
+
Using appearances to extend Page Builder's native content types represents one of Page Builder's best practices for creating a variety of new content building blocks based on existing content types.
0 commit comments