Skip to content

Commit b248c2b

Browse files
committed
MC-4272: Update content type docs
Add more configuration file instructions
1 parent bc03390 commit b248c2b

13 files changed

+96
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ We offer one method for installing PageBuilder:
3030
* [Introduction](docs/getting-started/introduction.md)
3131
* [Install Page Builder](docs/getting-started/install-pagebuilder.md)
3232
* [Activate Page Builder](docs/getting-started/activate-pagebuilder.md)
33+
* [View Page Builder](docs/getting-started/view-pagebuilder.md)
3334

3435
### Create a content type
3536

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# Content type Overview
1+
# Overview
22

33
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.
44

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

77
## Prerequisites
8+
{:.tutorial-before}
89

910
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.
1011

11-
![](../images/module-minimum-structure.png)
12+
![Minimum module structure](../images/module-minimum-structure.png)
1213

1314
## Overview
1415

15-
The steps for creating a Page Builder content type are briefly outlined here. The remainder of this topic describes these steps in detail.
16+
An overview of the steps for creating a Page Builder content type are briefly illustrated and described here.
1617

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

@@ -24,5 +25,10 @@ The steps for creating a Page Builder content type are briefly outlined here. Th
2425
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.
2526
7. **Add frontend widget**: a JavaScript file to control the UI behavior (user interactivity) of your content type on the storefront.
2627

28+
## Content type files
29+
30+
The files you will need to create in order to build a basic content type are shown here.
31+
2732
![Before and after content type](../images/content-type-files.png)
2833

34+
This tutorial walks you through creating these files, step by step.
Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,73 @@
1-
# Step 1: Add a configuration
1+
# Step 1: Add configuration
2+
3+
Creating a configuration file is the first step to creating a new content type. Through the configuration file, you can specify things like the label, location, and icon of your content type within the Page Builder panel menu. You can specify where your content type can be dropped on the stage, and reference the many other files you will use to control the appearance and behavior your content type.
4+
5+
## Create the configuration file
6+
7+
1. Create a new XML file in the following directory structure of your module: `view/adminhtml/pagebuilder/content_type/my-content-type.xml`.
8+
9+
2. Copy the contents of this example into your `my-content-type.xml` file:
10+
``` xml
11+
<?xml version="1.0"?>
12+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_PageBuilder:etc/content_type.xsd">
13+
<type name="my-content-type"
14+
label="My Content Type"
15+
group="layout"
16+
component="Magento_PageBuilder/js/content-type-collection"
17+
preview_component="Magento_PageBuilder/js/content-type/preview"
18+
master_component="Magento_PageBuilder/js/content-type/master"
19+
form=""
20+
icon=""
21+
sortOrder="-1"
22+
is_hideable="true"
23+
translate="label">
24+
<appearances>
25+
<appearance name="default"
26+
default="true"
27+
preview_template="Vendor_Module/content-type/my-content-type/default/preview"
28+
render_template="Vendor_Module/content-type/my-content-type/default/master"
29+
reader="Magento_PageBuilder/js/master-format/read/configurable">
30+
<elements>
31+
<element name="main">
32+
<attribute name="name" source="data-role"/>
33+
<attribute name="appearance" source="data-appearance"/>
34+
</element>
35+
</elements>
36+
</appearance>
37+
</appearances>
38+
</type>
39+
</config>
40+
```
41+
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+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Step 3: Add a component
1+
# Step 3: Add components
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Step 5: Add a layout
1+
# Step 5: Add layout
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Step 7: Add a frontend widget
1+
# Step 7: Add frontend widget
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# What's next
1+
# What's next?
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# View Page Builder
2+
3+
After activating Page Builder, you can view it by navigating to and editing any of your Magento CMS pages. For example, navigate to the Home Page editor by selecting **Content** > **Pages** > **Home Page** > **Edit**, as shown here:
4+
5+
![Navigate to Page Builder](../images/navigate-to-pagebuilder.png)
6+
7+
Then open the **Content** section on the Home Page to view Page Builder:
8+
9+
![View Page Builder](../images/home-page-pagebuilder.png)

docs/images/create-config-file-1.png

26.5 KB
Loading

docs/images/create-config-file.png

2.81 KB
Loading

0 commit comments

Comments
 (0)