├── examples ├── luma_homepage_admin.png ├── luma_homepage_storefront.png └── luma_homepage.html ├── registration.php ├── view ├── frontend │ ├── web │ │ ├── js │ │ │ └── content-type │ │ │ │ └── homepage-grid │ │ │ │ └── appearance │ │ │ │ └── default │ │ │ │ └── widget.js │ │ └── css │ │ │ └── source │ │ │ └── _module.less │ └── layout │ │ └── default.xml └── adminhtml │ ├── web │ ├── template │ │ └── content-type │ │ │ ├── homepage-grid │ │ │ └── default │ │ │ │ ├── master.html │ │ │ │ └── preview.html │ │ │ └── homepage-grid-item │ │ │ └── default │ │ │ ├── master.html │ │ │ └── preview.html │ ├── js │ │ └── content-type │ │ │ ├── homepage-grid-item │ │ │ └── preview.js │ │ │ └── homepage-grid │ │ │ └── preview.js │ └── css │ │ └── source │ │ └── _module.less │ ├── layout │ ├── pagebuilder_homepage_grid_form.xml │ └── pagebuilder_homepage_grid_item_form.xml │ ├── ui_component │ ├── pagebuilder_homepage_grid_form.xml │ └── pagebuilder_homepage_grid_item_form.xml │ └── pagebuilder │ └── content_type │ ├── homepage_grid.xml │ └── homepage_grid_item.xml ├── etc ├── module.xml └── adminhtml │ └── di.xml ├── composer.json └── README.md /examples/luma_homepage_admin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davemacaulay/module-page-builder-grid/HEAD/examples/luma_homepage_admin.png -------------------------------------------------------------------------------- /examples/luma_homepage_storefront.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davemacaulay/module-page-builder-grid/HEAD/examples/luma_homepage_storefront.png -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 |
11 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/content-type/homepage-grid-item/default/master.html: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 |
11 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/content-type/homepage-grid/default/preview.html: -------------------------------------------------------------------------------- 1 | 7 | 8 |
13 | 14 | 15 |
16 | -------------------------------------------------------------------------------- /view/adminhtml/layout/pagebuilder_homepage_grid_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /view/adminhtml/layout/pagebuilder_homepage_grid_item_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "davemacaulay/module-page-builder-grid", 3 | "description": "Example Page Builder Grid Module", 4 | "version": "1.0.0", 5 | "require": { 6 | "magento/framework": "*", 7 | "magento/module-page-builder": "*", 8 | "php": "~7.1.3||~7.2.0||~7.3.0" 9 | }, 10 | "type": "magento2-module", 11 | "license": [ 12 | "proprietary" 13 | ], 14 | "authors": [ 15 | { 16 | "name": "Dave Macaulay", 17 | "email": "macaulay@adobe.com" 18 | }, 19 | { 20 | "name": "Hwashiang Yu", 21 | "email": "hwyu@adobe.com" 22 | } 23 | ], 24 | "autoload": { 25 | "files": [ 26 | "registration.php" 27 | ], 28 | "psr-4": { 29 | "DaveMacaulay\\PageBuilderGrid\\": "" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /view/adminhtml/web/template/content-type/homepage-grid-item/default/preview.html: -------------------------------------------------------------------------------- 1 | 7 | 8 |
13 | 14 | 15 | 16 |
17 |
18 |
19 |
20 |
21 | -------------------------------------------------------------------------------- /view/frontend/layout/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | DaveMacaulay_PageBuilderGrid/js/content-type/homepage-grid/appearance/default/widget 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /view/frontend/web/css/source/_module.less: -------------------------------------------------------------------------------- 1 | // /** 2 | // * Copyright © Magento, Inc. All rights reserved. 3 | // * See COPYING.txt for license details. 4 | // */ 5 | 6 | .pagebuilder-homepage-grid { 7 | &:extend(.page-main); 8 | margin: 0 auto !important; 9 | padding: 0 20px !important; 10 | display: grid; 11 | grid-gap: 10px; 12 | grid-template-columns: 1fr 1fr 1fr; 13 | grid-template-rows: 270px 370px 270px; 14 | 15 | .pagebuilder-homepage-grid-item { 16 | &:nth-child(1) { 17 | grid-column: ~"2 / 4"; 18 | grid-row: 1; 19 | } 20 | &:nth-child(2) { 21 | grid-column: 1 ; 22 | grid-row: ~"1 / 3"; 23 | } 24 | &:nth-child(3) { 25 | grid-column: 2; 26 | grid-row: 2; 27 | } 28 | &:nth-child(4) { 29 | grid-column: 3; 30 | grid-row: ~"2 / 4"; 31 | } 32 | &:nth-child(5) { 33 | grid-column: ~"1 / 3"; 34 | grid-row: 3; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/content-type/homepage-grid-item/preview.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'underscore', 4 | 'Magento_PageBuilder/js/content-type/preview-collection', 5 | ], function ($, _, PreviewCollection) { 6 | 'use strict'; 7 | var $super; 8 | 9 | /** 10 | * Preview Constructor 11 | * 12 | * @param parent 13 | * @param config 14 | * @param stageId 15 | * @constructor 16 | */ 17 | function Preview(parent, config, stageId) { 18 | PreviewCollection.call(this, parent, config, stageId); 19 | } 20 | Preview.prototype = Object.create(PreviewCollection.prototype); 21 | $super = PreviewCollection.prototype; 22 | 23 | /** 24 | * Remove move, duplicate and remove options 25 | * 26 | * @returns {*} 27 | */ 28 | Preview.prototype.retrieveOptions = function retrieveOptions() { 29 | var options = $super.retrieveOptions.call(this, arguments); 30 | delete options.move; 31 | delete options.duplicate; 32 | delete options.remove; 33 | return options; 34 | }; 35 | 36 | return Preview; 37 | }); 38 | -------------------------------------------------------------------------------- /view/adminhtml/web/css/source/_module.less: -------------------------------------------------------------------------------- 1 | // /** 2 | // * Copyright © Magento, Inc. All rights reserved. 3 | // * See COPYING.txt for license details. 4 | // */ 5 | 6 | .pagebuilder-homepage-grid.pagebuilder-content-type.type-container { 7 | border: none; 8 | outline: none; 9 | 10 | > .element-children { 11 | display: grid; 12 | grid-gap: 10px; 13 | grid-template-columns: 1fr 1fr 1fr; 14 | grid-template-rows: 270px 370px 270px; 15 | 16 | > .pagebuilder-content-type-wrapper { 17 | height: 100%; 18 | 19 | &:nth-child(1) { 20 | grid-column: ~"2 / 4"; 21 | grid-row: 1; 22 | } 23 | &:nth-child(2) { 24 | grid-column: 1 ; 25 | grid-row: ~"1 / 3"; 26 | } 27 | &:nth-child(3) { 28 | grid-column: 2; 29 | grid-row: 2; 30 | } 31 | &:nth-child(4) { 32 | grid-column: 3; 33 | grid-row: ~"2 / 4"; 34 | } 35 | &:nth-child(5) { 36 | grid-column: ~"1 / 3"; 37 | grid-row: 3; 38 | } 39 | 40 | .pagebuilder-homepage-item { 41 | height: 100%; 42 | 43 | > .element-children { 44 | height: 100%; 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento Page Builder - Homepage Grid 2 | 3 | This module serves as an example for how you can create relatively complex content types within the new Page Builder framework. This module was created to show how we can easily rebuild the Luma sample content using Page Builder. 4 | 5 | This module contains two content types, both with different purposes: 6 | - Homepage Grid 7 | - This is responsible for housing all of the grid items to build up the final grid. 8 | - By design this content type can only contain grid items, and is fixed to having 5 children for our specific rigid grid. 9 | - Homepage Grid Item 10 | - This acts very much like a row or a column, housing the internal content and providing various background options. 11 | - This can contain any content type available in the framework (providing their configuration settings allow it) to generate rich content. 12 | 13 | ### Example 14 | Within this module we provide the master storage format contents for the luma homepage that's been presented alongside this module. 15 | 16 | **Admin View:** 17 | ![Luma Homepage Admin](examples/luma_homepage_admin.png "Luma Homepage Admin") 18 | 19 | **Storefront View:** 20 | ![Luma Homepage Storefront](examples/luma_homepage_storefront.png "Luma Homepage Storefront") 21 | 22 | This example can be imported into any Magento 2.3+ instance with Page Builder installed alongside this module. This can be done by updating the entities content to that provided in `examples/luma_homepage.html`. 23 | -------------------------------------------------------------------------------- /etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | large 12 | 13 | 14 | default 15 | Default 16 | 17 | 18 | 19 | 20 | 21 | 22 | large 23 | 24 | 25 | default 26 | Default 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /view/adminhtml/web/js/content-type/homepage-grid/preview.js: -------------------------------------------------------------------------------- 1 | define([ 2 | 'jquery', 3 | 'knockout', 4 | 'Magento_PageBuilder/js/events', 5 | 'underscore', 6 | 'Magento_PageBuilder/js/content-type/preview-collection', 7 | 'Magento_PageBuilder/js/content-type-factory', 8 | 'Magento_PageBuilder/js/config', 9 | ], function ($, ko, events, underscore, PreviewCollection, createContentType, pageBuilderConfig) { 10 | 'use strict'; 11 | 12 | /** 13 | * Preview Constructor 14 | * 15 | * @param parent 16 | * @param config 17 | * @param stageId 18 | * @constructor 19 | */ 20 | function Preview(parent, config, stageId) { 21 | var self = this; 22 | 23 | PreviewCollection.call(this, parent, config, stageId); 24 | 25 | events.on("homepage-grid:dropAfter", function (args) { 26 | if (args.id === self.contentType.id && self.contentType.children().length === 0) { 27 | // Once the grid is ready, let's add in our children 28 | self.populateGrid(); 29 | } 30 | }); 31 | } 32 | Preview.prototype = Object.create(PreviewCollection.prototype); 33 | 34 | /** 35 | * Populate the grid with 5 children 36 | */ 37 | Preview.prototype.populateGrid = function () { 38 | var self = this; 39 | var i; 40 | 41 | // Create 5 homepage grid items 42 | for (i = 0; i < 5; i++) { 43 | console.log(this.contentType); 44 | createContentType( 45 | pageBuilderConfig.getContentTypeConfig("homepage-grid-item"), 46 | this.contentType, 47 | this.contentType.stageId 48 | ).then(function (gridItem) { 49 | self.contentType.addChild(gridItem); 50 | }); 51 | } 52 | }; 53 | 54 | /** 55 | * Mark as not a standard container 56 | * 57 | * @returns {boolean} 58 | */ 59 | Preview.prototype.isContainer = function () { 60 | return false; 61 | }; 62 | 63 | return Preview; 64 | }); 65 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/pagebuilder_homepage_grid_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 |
9 | 10 | 11 | pagebuilder_homepage_grid_form.pagebuilder_homepage_grid_form_data_source 12 | 13 | Grid 14 | 15 | 16 | 17 | pagebuilder_homepage_grid_form.pagebuilder_homepage_grid_form_data_source 18 | 19 | pagebuilder_homepage_grid_form 20 | 21 | 22 | 23 | 24 | Magento_PageBuilder/js/form/provider 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | 36 | 37 | 38 | true 39 | 40 | false 41 | true 42 | 43 | ${$.name}.appearance:options 44 | ${$.name}.appearance:options 45 | 46 | 47 | 48 | 49 | 50 | default 51 | 52 | 53 | 54 | 55 | true 56 | true 57 | 58 | text 59 | 60 | true 61 | 62 | Magento_PageBuilder/form/element/visual-select 63 | 64 | 65 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | false 77 | 78 | 79 |
80 |
81 | 82 | 83 | 84 | {"margin":{"bottom":"10","left":"0","right":"0","top":"0"},"padding":{"bottom":"0","left":"0","right":"0","top":"0"}} 85 | 86 | 87 | 88 |
89 |
90 | -------------------------------------------------------------------------------- /view/adminhtml/ui_component/pagebuilder_homepage_grid_item_form.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 |
9 | 10 | 11 | pagebuilder_homepage_grid_item_form.pagebuilder_homepage_grid_item_form_data_source 12 | 13 | Grid Item 14 | 15 | 16 | 17 | pagebuilder_homepage_grid_item_form.pagebuilder_homepage_grid_item_form_data_source 18 | 19 | pagebuilder_homepage_grid_item_form 20 | 21 | 22 | 23 | 24 | Magento_PageBuilder/js/form/provider 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 | 36 | 37 | 38 | true 39 | 40 | false 41 | true 42 | 43 | ${$.name}.appearance:options 44 | ${$.name}.appearance:options 45 | 46 | 47 | 48 | 49 | 50 | default 51 | 52 | 53 | 54 | 55 | true 56 | true 57 | 58 | text 59 | 60 | true 61 | 62 | Magento_PageBuilder/form/element/visual-select 63 | 64 | 65 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | false 77 | 78 | 79 |
80 |
81 | 82 | 83 | 84 | {"margin":{"bottom":"0","left":"0","right":"0","top":"0"},"padding":{"bottom":"10","left":"10","right":"10","top":"10"}} 85 | 86 | 87 | 88 |
89 |
90 | -------------------------------------------------------------------------------- /view/adminhtml/pagebuilder/content_type/homepage_grid.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 | 33 |