Skip to content

Commit 5731a73

Browse files
committed
MC-4272: Update content type docs
More progress on the basic content type tutorial
1 parent b248c2b commit 5731a73

10 files changed

+66
-36
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ We offer one method for installing PageBuilder:
4949
* [Main configurations](docs/configurations/content-type-configuration.md)
5050
* [Additional configurations](docs/configurations/additional-configurations.md)
5151
* [Panel configurations](docs/configurations/panel-configurations.md)
52+
* [Option menu configurations](docs/configurations/option-menu-configurations.md)
5253
* [Iconography](docs/configurations/iconography.md)
5354
* [Block chooser configuration](docs/configurations/block-chooser-configuration.md)
5455
* [Full-width page layout configuration](docs/configurations/full-width-page-layout-configuration.md)
@@ -60,6 +61,9 @@ We offer one method for installing PageBuilder:
6061

6162
### How Tos
6263

64+
* [How to develop a new content type](docs/how-to/how-to-develop-new-content-type.md)
65+
* [How to develop a container content type](docs/how-to/how-to-develop-container-content-type.md)
66+
* [How to use the Image Uploader](docs/how-to/how-to-use-image-uploader.md)
6367
* [How to use the Image Uploader](docs/how-to/how-to-use-image-uploader.md)
6468
* [How to add inline text editing](docs/how-to/how-to-add-inline-text-editing.md)
6569
* [How to add a custom toolbar](docs/how-to/how-to-add-custom-toolbar.md)

docs/configurations/content-type-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Use the content type and group configuration to add new content types, extend ex
1515
| `children` | List of children content types that can accept this type as a parent. |
1616
| `appearances` | Appearance configuration. |
1717
| `is_visible` | Determines menu visibility for the component. System components should not be visible in the menu. Default value is true. |
18-
| `additional_data` | Allows to specify additional data for component, see [custom configuration for content type](data-configuration.md) for more information. |
18+
| `additional_data` | Allows to specify additional data for component, see [additional configurations](additional-configurations.md) for more information. |
1919

2020
| Attribute | Description |
2121
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Option menu configurations

docs/create-basic-content-type/overview.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Overview
22

3+
> NOTE: The development of this tutorial is currently IN PROGRESS. A more complete rough draft is available in the How Tos section here: [How to develop a new content type](docs/how-to/how-to-develop-new-content-type.md). When this tutorial is complete, it will replace the equivalent How To.
4+
35
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.
46

57
![Page Builder Content Types](../images/panel-horizontal.png)
@@ -18,8 +20,8 @@ An overview of the steps for creating a Page Builder content type are briefly il
1820
![Creating Custom Content Types](../images/content-type-overview.png)
1921

2022
1. **Add configuration**: an XML file to setup all the other files that control the appearances and behaviors of your content type.
21-
2. **Add templates**: HTML files to control the appearance of your content types on the Admin stage (preview.html) and the storefront (master.html).
22-
3. **Add component**: a JavaScript file to control the behavior of your content type on the Admin stage (preview.js) and the storefront (master.js).
23+
2. **Add templates**: HTML files that define the appearance of your content types on the Admin stage (preview.html) and the storefront (master.html).
24+
3. **Add component**: a JavaScript file that define the behavior of your content type on the Admin stage (preview.js) and the storefront (master.js).
2325
4. **Add form (editor)**: a UI component (XML file) to give users the ability to add or edit content using your content type.
2426
5. **Add layout**: an XML file to add your form editor to the stage.
2527
6. **Add styles and icons**: LESS and image files (png, svg) to add specific styling and images to your content types as they appear on the Admin stage and the storefront.
@@ -31,4 +33,4 @@ The files you will need to create in order to build a basic content type are sho
3133

3234
![Before and after content type](../images/content-type-files.png)
3335

34-
This tutorial walks you through creating these files, step by step.
36+
This tutorial walks you through creating these files, starting with [Step 1: Add configuration](step-1-add-configuration.md).

docs/create-basic-content-type/step-1-add-configuration.md

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Creating a configuration file is the first step to creating a new content type.
66

77
1. Create a new XML file in the following directory structure of your module: `view/adminhtml/pagebuilder/content_type/my-content-type.xml`.
88

9+
![Create config file](../images/create-config-file.png)
10+
911
2. Copy the contents of this example into your `my-content-type.xml` file:
1012
``` xml
1113
<?xml version="1.0"?>
@@ -39,35 +41,4 @@ Creating a configuration file is the first step to creating a new content type.
3941
</config>
4042
```
4143

42-
3. Create the required `preview_template` and `render_template` as specified in the configuration file.
43-
44-
Before seeing the results of our configuration in the Page Builder panel menu, we need to create the two templates specified in the <appearance> element of the configuration file:
45-
* preview.html - to display our content type within the Admin UI.
46-
* master.html - to display our content type within the CMS page on the storefront.
47-
48-
Both templates are required. So for now, just create the files within the following directory structure, `view/adminhtml/web/template/content_type/my-content-type/default/`, using the example content that follows. We will discuss them in detail later:
49-
50-
```html
51-
<!--preview.html-->
52-
<div class="pagebuilder-content-type" event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
53-
<render args="getOptions().template" />
54-
<div attr="data.main.attributes" css="data.main.css" ko-style="data.main.style">
55-
<div style="width: 100%; height: 100px; background-color: #f1f1f1; padding: 20px;">Admin template</div>
56-
</div>
57-
</div>
58-
```
59-
60-
```html
61-
<!--master.html-->
62-
<div class="pagebuilder-content-type" event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
63-
<render args="getOptions().template" />
64-
<div attr="data.main.attributes" css="data.main.css" ko-style="data.main.style">
65-
<div style="width: 100%; height: 100px; background-color: #f1f1f1; padding: 20px;">Admin template</div>
66-
</div>
67-
</div>
68-
```
69-
70-
4. Flush your config cache `bin/magento cache:flush config` and view Page Builder from the Home Page editor (as a convenience for storefront viewing later). The Page Builder panel menu should show your content type at the top of the layout group:
71-
72-
![Page Builder Panel Config](../images/create-config-file-1.png)
73-
44+
If you try to view Page Builder at this point, Page Builder will throw an error noting that the `preview_template` and `render_template` from the `<appearance` element are missing. These templates are required before we can add our content type to Page Builder. Let's do that in [Step 2: Add templates](step-2-add-templates.md).
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
11
# Step 2: Add templates
2+
3+
Page Builder templates are HTML files that define the appearance of content types within both the Admin UI (using the preview.html) and the storefront UI (using the master.html). Content types cannot be rendered without these templates, so let's create the ones already specified in the `<appearance>` element of our configuration file.
4+
5+
``` xml
6+
<appearance name="default"
7+
default="true"
8+
preview_template="Vendor_Module/content-type/my-content-type/default/preview"
9+
render_template="Vendor_Module/content-type/my-content-type/default/master"
10+
reader="Magento_PageBuilder/js/master-format/read/configurable">
11+
```
12+
13+
1. Create the `preview_template` and `render_template` files (as noted above) within the specified directory structure, `view/adminhtml/web/template/content_type/my-content-type/default/`, using the example content that follows.
14+
15+
![Page Builder templates](../images/templates-directory-structure.png)
16+
17+
```html
18+
<!--master.html-->
19+
<div attr="data.main.attributes" ko-style="data.main.style" css="data.main.css">
20+
<div attr="data.main.attributes" css="data.main.css" ko-style="data.main.style">
21+
<div style="width: 100%; height: 100px; background-color: #cccccc;">Storefront UI template</div>
22+
</div>
23+
</div>
24+
```
25+
26+
```html
27+
<!--preview.html-->
28+
<div class="pagebuilder-content-type" event="{ mouseover: onMouseOver, mouseout: onMouseOut }, mouseoverBubble: false">
29+
<render args="getOptions().template" />
30+
<div attr="data.main.attributes" css="data.main.css" ko-style="data.main.style">
31+
<div style="width: 100%; height: 100px; background-color: #f1f1f1; padding: 20px;">Admin UI template</div>
32+
</div>
33+
</div>
34+
```
35+
36+
2. Flush your config cache `bin/magento cache:flush config` and view Page Builder from the Home Page editor (as a convenience for storefront viewing later). The Page Builder panel menu should show your content type at the top of the layout group:
37+
38+
![Page Builder Panel Config](../images/create-config-file-1.png)
39+
40+
3. Drag your new content type onto the stage and **Save**. You should see something similar to this:
41+
42+
![Admin preview.html template](../images/drag-content-type-to-stage.png)
43+
44+
Notice that you also have an options menu when you hover over your content type. This is provided by including the `<render args="getOptions().template" />` within your `preview.html` template. See [Option menu configurations](option-menu-configurations.md) for more details.
45+
46+
4. Open the Home Page on the storefront to see how the `master.html` template renders, as shown here:
47+
48+
![Storefront master.html template](../images/content-type-master-template.png)
49+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Step 3: Add components
2+
3+
Components are JavaScript files that define the behavior of your content type within the Admin UI stage (using preview.js) and the storefront UI (using master.js).
4+
5+
1. Add a preview.js file to ...
5.7 KB
Loading
29.2 KB
Loading
3.81 KB
Loading

0 commit comments

Comments
 (0)