A talk covering how developers can add new content to BlueFoot CMS in Magento 2. More details available at: http://www.magetitans.it/discovering-bluefoot-john-hughes/
2. @JohnHughes1984
ABOUT ME
â˘Technical Director at Fisheye
â˘Working with Magento â 5 years
â˘Passionate about:
- Ensuring developers have tools / guidance
to work eďŹciently and follow best practice
- Providing best in class solutions for
merchants
- Being part of #RealMagento community
IMAGINE 2017â¨
MOST INNOVATIVE
WEBSITEâ¨
AWARD WINNERS
3. @JohnHughes1984
OVERVIEW
â˘What is BlueFoot?
â˘Developer overview of âPage Builder Blocksâ
â˘Creating a module to add BlueFoot âPage Builder Blocksâ
â˘Ideas for new content types and further customisation
â˘What the future holds for BlueFoot
5. @JohnHughes1984
LETâS HAVE A SHOW OF HANDS đ
â˘Who knows what BlueFoot is?
â˘Whoâs installed it or used it in a project?
â˘Whoâs extended it?
6.
7. â˘CMS & Page Builder for Magento
- Built by Gene Commerce
- Acquired by Magento in December 2015
â˘Drag & drop multiple content types in ďŹexible row / column layouts
â˘Can be used anywhere in admin where WYSIWYG area is present
16. @JohnHughes1984
BLUEFOOT ENTITY TYPE
⢠Not to be confused with standard
entity types
⢠BlueFoot Entity Type = â¨
Page Builder Block
- e.g. Image, Video, Slider
⢠âgene_bluefoot_entity_typeâ table
17. @JohnHughes1984
BLUEFOOT ENTITY TYPE GROUP
⢠BlueFoot Entity Types are assigned
to a âBlueFoot Entity Type Groupâ
- Menu group headings
- e.g. General, Media, Commerce
- âgene_bluefoot_entity_type_groupâ
table
19. @JohnHughes1984
ATTRIBUTE SETS
â˘All attributes can be added to an attribute set just like any other
EAV type
â˘Each âBlueFoot Entity Typeâ (âPage Builder Blockâ) is linked to a
unique attribute set of the same name
- e.g. the âDriverâ Page Builder Block has an accompanying
attribute set also named âDriverâ to store its attributes
20. @JohnHughes1984
ATTRIBUTE GROUPS
⢠Each âPage Builder Blocksâ
attribute set can be further split
into groups
⢠These groups map to tabs within
âPage Builder Blockâ edit panel
- e.g. Images, Link, Seo, Advanced
23. @JohnHughes1984
PAGE BUILDER BLOCK
â˘When it comes to rendering each âPage Builder Blockâ is assigned a block
class and template ďŹle
â˘âPage Builder Blocksâ can also have child items
- e.g. individual banners within a slider / carousel or items within an
accordion
- These child items are also âPage Builder Blocksâ (BlueFoot Entity Types)
but are generally hidden from the menu
24. @JohnHughes1984
ADDING NEW CONTENT
â˘BlueFoot allows creation / management of attributes sets (âPage
Builder Blocksâ) within the admin panel
â˘Block classes, templates & other settings can also be managed
â˘This is great⌠but for reusable solutions we need to build a
module
26. @JohnHughes1984
LIST BUILDER
Letâs create a list builder, made up of:
⢠A âListâ Page Builder Block - for <ul>
elements
⢠A child âList Itemsâ block - for <li>
elements
⢠A new âFisheyeâ group to display our
block under in BlueFoot menu
27. @JohnHughes1984
LIST PAGE BUILDER BLOCK
⢠Options
- List Title - text ďŹeld
- List Style - select - e.g. none, circle, disc etc.
⢠Items
- List Items - child_item - for List Item blocks
⢠Advanced
- CSS Classes - default attribute for CSS
28. @JohnHughes1984
LIST ITEM PAGE BUILDER BLOCK
⢠Options
- List Text - text ďŹeld
- List Icon - text ďŹeld - Font Awesome
⢠Link
- List Link URL - text ďŹeld
- Link Target - boolean
⢠Advanced
- CSS Classes - default attribute for CSS
29. @JohnHughes1984
MODULE COMPONENTS
⢠General module conďŹguration ďŹles
⢠BlueFoot speciďŹc conďŹguration ďŹles
⢠Install script and data source(s)
⢠View ďŹles - block classes and templates
⢠Static assets - CSS, JS, images etc.
30. @JohnHughes1984
GENERAL MODULE CONFIGURATION
As with any other module weâll need the basics:
â˘composer.json - declare dependency on gene/bluefoot package
â˘etc/module.xml - add Gene_BlueFoot to sequence node ensure correct load
order
â˘registration.php - registers module
31. @JohnHughes1984
BLUEFOOT SPECIFIC CONFIGURATION
BlueFoot has its own XML/XSD conďŹguration ďŹles:
â˘Renderers - block classes for use by Page Builder Blocks
â˘Templates - template ďŹles for for use by Page Builder Blocks
â˘Plugins - JS widgets e.g. colour picker, product search, maps
â˘Structural elements - e.g. rows and columns
33. @JohnHughes1984
INSTALL SCRIPT
â˘In essence the same as any other installer script
â˘To create new entity type group we need to inject
GeneBlueFootApiContentBlockGroupRepositoryInterface and
GeneBlueFootApiDataContentBlockGroupInterface
â˘Injecting GeneBlueFootModelInstallerFile we can import data
from JSON ďŹle rather than MagentoEavSetupEavSetup methods
34. @JohnHughes1984
Setup/InstallData.php
class InstallData implements InstallDataInterface
{
/** ⌠*/â¨
public function install(
ModuleDataSetupInterface $setup,
ModuleContextInterface $context
) {â¨
$setup->startSetup();â¨
$this->addContentBlockGroup();â¨
$this->installData($setup);â¨
$setup->endSetup();â¨
}
41. @JohnHughes1984
Setup/data/install-blocks-attributes.json
"attributes": [â¨
{â¨
"attribute_code": "list_style",â¨
"backend_model": null,â¨
"backend_type": "varchar",â¨
"frontend_input": "select",â¨
"frontend_label": ["List Style"],â¨
"source_model": "FisheyeBlueFootListModelEntityAttributeSourceListStyle",â¨
"is_required": "1",â¨
"is_user_defined": "1",â¨
"note": null,â¨
"is_visible": "1",â¨
"widget": null,â¨
"data_model": null,â¨
"entity_allowed_block_type": false
âŚ
},
âŚ
]
CUSTOM SOURCE MODEL
NEVER SET TO â0â AS WILL
ADD ATTRIBUTE TO ALL
ATTRIBUTES SETS!!!
FOR ADDING NEW ATTRIBUTES
42. @JohnHughes1984
Setup/data/install-blocks-attributes.json
"attributes": [â¨
{â¨
"attribute_code": "list_items",â¨
"backend_model": "MagentoEavModelEntityAttributeBackend
ArrayBackend",â¨
"backend_type": "text",â¨
"frontend_input": "child_entity",â¨
"frontend_label": ["List Items"],â¨
"source_model": "GeneBlueFootModelAttributeSourceEntity
Child",â¨
"entity_allowed_block_type": âfisheye_list_itemâ,
âŚâ¨
},
âŚ
]
BACKEND & SOURCE
MODEL REQUIRED FOR
CHILD BLOCK ATTRIBUTES
ENSURES ATTRIBUTE IS
ONLY USED FOR THE
SPECIFIED BLOCK TYPE
43. @JohnHughes1984
VIEW FILES
â˘Block classes / template ďŹles need to be placed as declared in
etc/bluefoot/pagebuilder.xml earlier
â˘Blocks extend GeneBlueFootBlockEntityPageBuilderBlockAbstractBlock
â˘Admin templates use mustache.js templates
- {{attribute_code}} handles are replaced via JS to update preview
44. @JohnHughes1984
Block/ListBlock.php
class ListBlock extends AbstractBlockâ¨
{â¨
/** ⌠*/â¨
public function getListTitle()â¨
{â¨
return $this->stripTags($this->getEntity()->getData('list_title'));â¨
}â¨
â¨
/** ⌠*/â¨
public function getListStyle()â¨
{â¨
return $this->getEntity()->getData('list_style');â¨
}â¨
}
45. @JohnHughes1984
Block/ListItem.php
class ListItem extends AbstractBlockâ¨
{â¨
/** ⌠*/â¨
public function getItemIcon()â¨
{â¨
return $this->stripTags($this->getEntity()->getData('list_item_icon'));â¨
}â¨
â¨
/** ⌠*/â¨
public function getItemLinkUrl()â¨
{â¨
return $this->escapeXssInUrl($this->getEntity()-
>getData('list_item_url'));â¨
}
âŚ
57. @JohnHughes1984
FURTHER POSSIBILITIES
â˘Menu builder
â˘Form builder
â˘Magento elements (e.g. advanced search, quick order)
â˘Social media feeds (e.g. Twitter / Facebook / Instagram)
â˘Content from other systems (e.g. WordPress posts via WP API)
58. @JohnHughes1984
FURTHER POSSIBILITIES CONT.
â˘Add new attribute types with rich content via plugins (JS widgets)
- Default widgets include:
⢠Colour picker, Google maps, video preview and entity search
e.g. products and categories
â˘New structural elements
59. @JohnHughes1984
FISHEYE USAGE
â˘At Fisheye weâve built our entire frontend around BlueFoot
- Page Builder Blocks - banners, trust, social and more
- Plugins (JS widgets) - CMS page search
- Wrapped into our own CMS framework
60. @JohnHughes1984
âPhillip Jackson, speaking during MageTalk Live at Magento Imagine 2017
âBLUEFOOT HAS GIVEN US A
âLEG UPâ TO SELL MAGENTO 2 IN
A BIGGER AND BROADER WAYâ
62. @JohnHughes1984
WHERE NEXT FOR BLUEFOOT?
â˘Fully integrated in Magento v2.3 as âMagento Advanced CMSâ
- Expected late 2017âŚ
â˘Majority of functionality will be for âEnterprise Edition onlyâ
â˘Core version integrated into Magento UI with native drag & drop
â˘Integration of Adobe CC image editing
63. @JohnHughes1984
THANK YOU FOR LISTENING! đ
Want to know more / see a demo? Come say hi đŹđť or get in touch:
â˘Twitter: @JohnHughes1984
â˘Email: johnh@ďŹsheyehq.com
â˘LinkedIn: linkedin.com/in/johnhughes1984
64. @JohnHughes1984
Q&A
â˘Will this example / way of extending be relevant once 2.3 released?
- Unsure, better directed at Magento core team
- At very least vendor and namespaces will change and given the plans to refactor natively there
are bound to be further changes required, but conďŹdent most of concepts will remain similar and
hopefully porting extensions shouldnât be too large a task (not exactly large modules)
â˘How do I get BlueFoot?
- Using composer (requires Enterprise Edition access keys) - composer require gene/bluefoot
- Download via partner portal