Skip to content

Commit d8c9046

Browse files
committed
MAGEDOC-3430: Clarify Storefront customization
Changed from a configuration topic to a how-to topic
1 parent d7f736a commit d8c9046

File tree

3 files changed

+21
-83
lines changed

3 files changed

+21
-83
lines changed

docs/configurations/storefront-configuration.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

docs/getting-started/introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ See [Install Page Builder](install-pagebuilder.md)
6060
### Reference
6161

6262
* [Architecture](../reference/architecture.md)
63+
* [Datastore](../reference/data-store.md)
6364
* [Events](../reference/events.md)
6465
* [Knockout bindings](../reference/knockout-bindings.md)
6566

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
# Storefront customization
1+
# How to add a storefront widget
22

3-
A storefront widget is JavaScript code that handles the behavior of a content type after Page Builder renders it on the storefront. For example, the Tabs and Sliders have their own storefront widgets to handle the end-user's tapping of tabs and the swiping of slides.
3+
A storefront widget is a JavaScript component that handles the behavior of a content type after Page Builder renders it on the storefront.
4+
For example, the Tabs and Sliders have their own storefront widgets to handle the end-user's tapping of tabs and swiping of slides on the storefront.
5+
However, Page Builder also executes storefront widgets on the Admin stage for block and dynamic block content types.
6+
This allows end-users to preview how Page Builder will render the blocks and dynamic blocks on the storefront.
47

58
Adding a storefront widget to your content type is a simple two-step process:
69

7-
8-
910
![How to add storefront widget](../images/how-to-add-storefront-widget.svg)
1011

11-
12-
1312
## Step 1: Create the JavaScript
1413

1514
Name your JavaScript file `widget.js` and put it in the following directory structure: `/view/base/web/js/content-type/{content-type-name}/appearance/{appearance-name}/widget.js`. An example from the PageBuilderQuote content type follows:
1615

1716
![Where to add storefront widget](../images/where-to-add-widget.png){:width="477px" height="auto"}
1817

19-
The JavaScript for the widget can handle events, initialize third-party controls, or do whatever else you need in order to control your content type's behavior _after_ Page Builder renders the master format template on the frontend.
18+
The JavaScript for the widget can handle events, initialize third-party controls, or do whatever else you need to control your content type's behavior _after_ Page Builder renders the master format template on the frontend (or within a block or dynamic block on the Admin stage).
2019

2120
``` javascript
2221
define([
@@ -33,31 +32,24 @@ define([
3332

3433
## Step 2: Configure the widget initializer
3534

36-
To configure your `widget.js` so that Page Builder can initialize and load it on the storefront, create a new `WidgetInitializerConfig` type in your module's global `di.xml` file (`etc/di.xml`). Then add your configuration (that includes your widget) as a replacement argument. The following example is from the PageBuilderQuote module:
35+
To configure your `widget.js` so that Page Builder can initialize and load it, create a new `WidgetInitializerConfig` type in your module's global `di.xml` file (`etc/di.xml`). Then add your custom configuration (that includes your widget) as a replacement argument. The following example is from the PageBuilderQuote module:
3736

3837
``` xml
3938
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
40-
<type name="Magento\PageBuilder\Model\WidgetInitializerConfig">
41-
<arguments>
42-
<argument name="config" xsi:type="array">
43-
<item name="example_quote" xsi:type="array">
44-
<!-- Name is the appearance name -->
45-
<item name="default" xsi:type="array">
46-
<!--required argument-->
47-
<item name="component" xsi:type="string">Example_PageBuilderQuote/js/content-type/example-quote/appearance/default/widget</item>
39+
<type name="Magento\PageBuilder\Model\WidgetInitializerConfig">
40+
<arguments>
41+
<argument name="config" xsi:type="array">
42+
<item name="example_quote" xsi:type="array">
43+
<!-- Name is the appearance name -->
44+
<item name="default" xsi:type="array">
45+
<!--required argument-->
46+
<item name="component" xsi:type="string">Example_PageBuilderQuote/js/content-type/example-quote/appearance/default/widget</item>
47+
</item>
4848
</item>
49-
</item>
50-
</argument>
51-
</arguments>
52-
</type>
49+
</argument>
50+
</arguments>
51+
</type>
5352
</config>
5453
```
5554

56-
The XML configuration loads the widget on the frontend, and on the stage, so you can preview content inside both the block and dynamic block content types.
57-
58-
**^^^ I don't understand the reference to blocks and dynamic blocks in the previous sentence.**
59-
60-
**^^^ Is the `WidgetInitializerConfig` class just automatically instantiated for the frontend? When is it instantiated? During the rendering of the storefront/frontend?**
61-
62-
63-
55+
That's it! For more examples, look at several of Page Builder's native widget implementations within `app/code/Magento/PageBuilder/view/base/web/js/content-type/`.

0 commit comments

Comments
 (0)