Skip to content

Commit 8f4cecf

Browse files
committed
MC-4272: Update content type docs
Added images for content type creation
1 parent cdebf03 commit 8f4cecf

File tree

6 files changed

+60
-33
lines changed

6 files changed

+60
-33
lines changed

docs/configurations/panel-configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You can customize the panel menu in four ways:
1717

1818
To rename the panel groups, you need to override the defaults configured in the Page Builder `group.xml` file as follows:
1919

20-
1. Add a file called `group.xml` to your module's `view/adminhtml/pagebuilder/` directory:
20+
1. Add a file named `group.xml` to your module's `view/adminhtml/pagebuilder/` directory:
2121

2222
![Custom group file](../images/custom-group-file.png)
2323

docs/how-to/how-to-develop-new-content-type.md

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,26 @@
22

33
<!-- {% raw %} -->
44

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.
66

77
![Page Builder Content Types](../images/panel-horizontal.png)
88

99
## Prerequisites
1010

11-
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+
![](../images/module-minimum-structure.png)
1214

1315
## Overview
1416

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.
1618

1719
![Creating Custom Content Types](../images/content-type-overview.png)
1820

19-
1. Add a configuration:
20-
2. Add templates:
21-
3. Add components:
22-
4. Add forms:
23-
5. Add layouts:
24-
6. Add styles and icons:
25-
7. Add a frontend widget:
21+
22+
23+
![Before and after content type](../images/content-type-files.png)
24+
2625

2726

2827
## Step 1: Add a configuration
@@ -71,6 +70,8 @@ To add configuration for a new content type, create a file under the following l
7170

7271
In this example, content type has only one element in the template.
7372

73+
## Step 2: Add a template
74+
7475
Let's create templates specified in the configuration.
7576

7677
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
9192
<div attr="data.main.attributes" ko-style="data.main.style" css="data.main.css" html="data.main.html"></div>
9293
```
9394

94-
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) {
109+
var Simple = function() {
110+
Preview.apply(this, arguments);
111+
};
112+
113+
Simple.prototype = Object.create(Preview.prototype);
114+
Simple.prototype.constructor = Simple;
115+
116+
/**
117+
* Alert Hello World
118+
*/
119+
Simple.prototype.helloWorld = function() {
120+
alert("Hello World");
121+
};
122+
123+
return Simple;
124+
});
125+
```
126+
127+
128+
129+
## Step 4: Add an icon
130+
131+
132+
133+
## Step 5: Add a form
134+
135+
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.
95136

96137
``` XML
97138
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd" extends="pagebuilder_base_form">
@@ -173,6 +214,8 @@ Every form should have default appearance to allow other modules to add more app
173214

174215
Attributes that we want to edit as part of the advanced section are defined in `pagebuilder_base_form`, so we can just extend it.
175216

217+
## Step 6: Add a layout
218+
176219
And to allow this form to be loaded in PageBuilder, let's create layout `Vendor/ModuleName/view/adminhtml/layout/pagebuildercustom_simple_form.xml`.
177220

178221
``` XML
@@ -186,35 +229,19 @@ And to allow this form to be loaded in PageBuilder, let's create layout `Vendor/
186229
</page>
187230
```
188231

189-
## Preview, PreviewCollection, Content, and ContentCollection
190232

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.
192233

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
194235

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+
196237

197-
Let's add a button in the preview that would display `Hello World` on click.
198238

199-
``` js
200-
define(["Magento_PageBuilder/js/content-type/preview"], function (Preview) {
201-
var Simple = function() {
202-
Preview.apply(this, arguments);
203-
};
204239

205-
Simple.prototype = Object.create(Preview.prototype);
206-
Simple.prototype.constructor = Simple;
207240

208-
/**
209-
* Alert Hello World
210-
*/
211-
Simple.prototype.helloWorld = function() {
212-
alert("Hello World");
213-
};
214241

215-
return Simple;
216-
});
217-
```
242+
243+
244+
## Preview, PreviewCollection, Content, and ContentCollection
218245

219246
And the last part is to add button to a template.
220247

docs/images/content-type-files.png

166 KB
Loading

docs/images/content-type-overview.png

-425 Bytes
Loading
Loading
4.01 KB
Loading

0 commit comments

Comments
 (0)