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-develop-new-content-type.md
+59-32Lines changed: 59 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,26 @@
2
2
3
3
<!-- {% raw %} -->
4
4
5
-
Out of the box, Page Builder comes with several content types (controls) that you can drag onto the stage to build your storefront pages, as shown below. In this topic, you will learn how to create your own content types for use within Page Builder.
5
+
Out of the box, Page Builder comes with several content types (controls) that you can drag onto the stage to build your storefront pages, as shown below. In this topic, you will learn how to create your own content type for use within Page Builder.
Content types are implemented as modules. Therefore, this topic assumes you have already created a basic Magento module structure in which to add your content type files. **[Add a link to devdocs module topic]**
11
+
Page Builder creates content types from modules. So this topic assumes you have a basic module structure in which to add your content type files.
12
+
13
+

12
14
13
15
## Overview
14
16
15
-
The steps for creating a Page Builder content type are briefly illustrated and outlined here. The remainder of this topic describes these steps in detail.
17
+
The steps for creating a Page Builder content type are briefly outlined here. The remainder of this topic describes these steps in detail.

24
+
26
25
27
26
28
27
## Step 1: Add a configuration
@@ -71,6 +70,8 @@ To add configuration for a new content type, create a file under the following l
71
70
72
71
In this example, content type has only one element in the template.
73
72
73
+
## Step 2: Add a template
74
+
74
75
Let's create templates specified in the configuration.
75
76
76
77
Optional: For template knockout bindings, you can use the original data-bind syntax, or utilize Magento custom Knockout.js bindings as seen in the template snippets below. `http://devdocs.magento.com/guides/v2.2/ui_comp_guide/concepts/knockout-bindings.html`
@@ -91,7 +92,47 @@ And master template `app/code/Vendor/ModuleName/view/adminhtml/web/template/cont
In the `simple.xml` above we defined border attributes and form for component. Let's create form `Vendor/ModuleName/view/adminhtml/ui_component/modulename_simple_form.xml` which enables the user to modify these attributes from the admin.
95
+
In the `simple.xml` above we defined border attributes and form for component.
96
+
97
+
## Step 3: Add a component
98
+
99
+
If your content type has custom preview logic, you need to specify `preview_component`, otherwise the default one `Magento_PageBuilder/js/content-type/preview` will be used.
100
+
101
+
If your content type can have other components as children, you need to extend `Magento_PageBuilder/js/content-type/preview-collection` component. Otherwice you need to extend `Magento_PageBuilder/js/content-type/preview`.
102
+
103
+
In the preview component you can add custom logic that will be available in the template. You can also do modifications to observables used in preview template if you override `afterObservablesUpdated` method.
104
+
105
+
Let's add a button in the preview that would display `Hello World` on click.
106
+
107
+
```js
108
+
define(["Magento_PageBuilder/js/content-type/preview"], function (Preview) {
Let's create form `Vendor/ModuleName/view/adminhtml/ui_component/modulename_simple_form.xml` which enables the user to modify these attributes from the admin.
@@ -173,6 +214,8 @@ Every form should have default appearance to allow other modules to add more app
173
214
174
215
Attributes that we want to edit as part of the advanced section are defined in `pagebuilder_base_form`, so we can just extend it.
175
216
217
+
## Step 6: Add a layout
218
+
176
219
And to allow this form to be loaded in PageBuilder, let's create layout `Vendor/ModuleName/view/adminhtml/layout/pagebuildercustom_simple_form.xml`.
177
220
178
221
```XML
@@ -186,35 +229,19 @@ And to allow this form to be loaded in PageBuilder, let's create layout `Vendor/
186
229
</page>
187
230
```
188
231
189
-
## Preview, PreviewCollection, Content, and ContentCollection
190
232
191
-
If your content type has custom preview logic, you need to specify `preview_component`, otherwise the default one `Magento_PageBuilder/js/content-type/preview` will be used.
192
233
193
-
If your content type can have other components as children, you need to extend `Magento_PageBuilder/js/content-type/preview-collection` component. Otherwice you need to extend `Magento_PageBuilder/js/content-type/preview`.
234
+
## Step 7: Add a frontend widget
194
235
195
-
In the preview component you can add custom logic that will be available in the template. You can also do modifications to observables used in preview template if you override `afterObservablesUpdated` method.
236
+
196
237
197
-
Let's add a button in the preview that would display `Hello World` on click.
198
238
199
-
```js
200
-
define(["Magento_PageBuilder/js/content-type/preview"], function (Preview) {
0 commit comments