Content Context - boxalino/rtux-integration-magento2 GitHub Wiki
In the Boxalino ecosystem, content refers to any other data type (voucher, blogs, campaigns, banners, etc) which is integrated with the help of the narrative API.
content integration
Review the documentation forThe content of the response depends 100% on your design and layout blocks desired.
Before you start, the layout blocks & narrative layout must be defined in Boxalino Intelligence admin.
The Layout Blocks JSON & Narratives JSON from this page can be used as base.
If there is no narrative assigned to the choice/widget requested, the response will be empty.
Requirements
The declared Layout Blocks uses rtux-magento2 elements available in tag 2.0.0 and newer.
Review the composer.json for more details on dependencies.
Integration description
In the Layout Blocks JSON & Narrative Layout JSON sample provided , a "read" widget (a list of blogs) will be added to the page (user account).
The provided JSON samples for the Narrative layout and the Layout blocks must be imported in Boxalino Intelligence Admin
Steps
1. Identify the Layout Requirements
This is based 100% on your assigned feature integration task specifications. Identify the required layout, recognize the needed Layout Blocks segments, templates and data.
read the Layout Integration Guide on Confluence
If you are uncertain on how to start,For this sample, the Layout blocks and Layout is a mix of 2 elements: working with a generic collection item (bx-hit) and working with the block API element to access properties.
2. Prepare the templates for the designed layout blocks.
For the blog list sample, there are 2 different lists displayed in 2 different ways (via collection or via API block response). The following templates are used:
- the title (h3)
- a loop/list to render child blocks
- an item view which will show how to access properties from the bx-hit API element
- a block-item view in which the properties are accessed directly from the Layout Block (block) API response, based on the declared JSON schema.
The templates must be updated when switching to a real-case integration, in order to reflect the data part of your API response (returnFields property of the API Request)
3. Implement the Boxalino RTUX API ContextInterface
This is a generic step for any feature integration
As it is the most basic integration (ex: when extending from the provided base ContextAbstract ) - only 3 functions are left to be implemented in order to set:
- the products visibility (if needed)
- the products category (as filter - depends on the context)
- the return fields (which can be set via layout XML as well)
The filters list should include the filters for your OWN content logic by rewriting the addFilters(RequestInterface $request) function.
The returnFields must be set based on the required content for your display.
Create the Magento2 block
4.The Magento2 block can be generic and can be re-usable. Make sure to set the groupBy of the relevant field for your data context.
The API request is done on protected function _prepareLayout()
.
layout XML or for widget definitions, etc
5. Use the block in aWhen using the block, make sure to set the widget, hitCount, groupBy and the return fields (if desired). These properties are required on the ContextInterface object (step #2).
For this use-case it has been used the generic template from RTUX Magento2 which will render the content of the JSON API response in a loop.
Layout Blocks JSON
[{"id":1981,"uniqueKey":"rtux_content_item","parametersJsonScheme":"","format":null,"widgets":[],"parameters":[{"name":"content-resource","values":["c-r=t"]},{"name":"bx-hit","values":["accessor"]},{"name":"name","values":["rtux_content_item"]},{"name":"template","values":["BoxalinoClientProject_BoxalinoIntegration::api/element/content/item.phtml"]},{"name":"type","values":["Boxalino\\RealTimeUserExperience\\Block\\Api\\Item"]}],"subRenderings":[],"route":"visual-elements","reqParams":null,"$fromServer":true,"parentResource":null,"restangularCollection":false,"isSelected":true},{"id":1982,"uniqueKey":"rtux_content_list","parametersJsonScheme":"{\n \"title\": \"Content List(blog, product, etc)\",\n \"type\": \"object\",\n \"properties\": {\n \"content\": {\n \"type\": \"string\",\n \"description\": \"Content type\"\n },\n \"accessor\": {\n \"type\": \"string\",\n \"description\": \"accessor (for connection to other widgets)\"\n }\n }\n}","format":null,"widgets":[],"parameters":[{"name":"bx-hits","values":["accessor"]},{"name":"name","values":["rtux_content_list"]},{"name":"template","values":["BoxalinoClientProject_BoxalinoIntegration::api/element/content/list.phtml"]},{"name":"type","values":["Boxalino\\RealTimeUserExperience\\Block\\Api\\ListApi"]}],"subRenderings":[],"route":"visual-elements","reqParams":null,"$fromServer":true,"parentResource":null,"restangularCollection":false,"isSelected":true},{"id":1986,"uniqueKey":"rtux_content_block","parametersJsonScheme":"{\n \"title\": \"Content (blog, product, etc)\",\n \"type\": \"object\",\n \"properties\": {\n \"link\": {\n \"type\": \"object\",\n \"title\": \"Content URL\",\n \"properties\": {\n \"de\": {\n \"type\": \"string\",\n \"description\": \"Set Content View URL in German.\"\n },\n \"fr\": {\n \"type\": \"string\",\n \"description\": \"Set Content View URL in French.\"\n },\n \"it\": {\n \"type\": \"string\",\n \"description\": \"Set Content View URL in Italian.\"\n },\n \"en\": {\n \"type\": \"string\",\n \"description\": \"Set Content View URL in English.\"\n }\n }\n },\n \"image\": {\n \"type\": \"object\",\n \"title\": \"Image\",\n \"properties\": {\n \"de\": {\n \"type\": \"string\",\n \"description\": \"Set Image Source in German.\"\n },\n \"fr\": {\n \"type\": \"string\",\n \"description\": \"Set Image Source in French.\"\n },\n \"it\": {\n \"type\": \"string\",\n \"description\": \"Set Image Source in Italian.\"\n },\n \"en\": {\n \"type\": \"string\",\n \"description\": \"Set Image Source in English.\"\n }\n }\n },\n \"title\": {\n \"type\": \"object\",\n \"title\": \"Name\",\n \"properties\": {\n \"de\": {\n \"type\": \"string\",\n \"description\": \"Set Content title in German.\"\n },\n \"fr\": {\n \"type\": \"string\",\n \"description\": \"Set Content title in French.\"\n },\n \"it\": {\n \"type\": \"string\",\n \"description\": \"Set Content title in Italian.\"\n },\n \"en\": {\n \"type\": \"string\",\n \"description\": \"Set Content title in English.\"\n }\n }\n },\n \"description\": {\n \"type\": \"object\",\n \"title\": \"Content Description\",\n \"properties\": {\n \"de\": {\n \"type\": \"string\",\n \"description\": \"Set Content details in German.\"\n },\n \"fr\": {\n \"type\": \"string\",\n \"description\": \"Set Content details in French.\"\n },\n \"it\": {\n \"type\": \"string\",\n \"description\": \"Set Content details in Italian.\"\n },\n \"en\": {\n \"type\": \"string\",\n \"description\": \"Set Content details in English.\"\n }\n }\n }\n }\n}","format":null,"widgets":[],"parameters":[{"name":"content-resource","values":["c-r=t"]},{"name":"bx-hit","values":["accessor"]},{"name":"name","values":["rtux_content_item"]},{"name":"template","values":["BoxalinoClientProject_BoxalinoIntegration::api/element/content/block.phtml"]}],"subRenderings":[],"route":"visual-elements","reqParams":null,"$fromServer":true,"parentResource":null,"restangularCollection":false,"isSelected":true}]
Narrative Layout JSON
[{"id":1759,"status":null,"uniqueKey":"content_blog","aliases":null,"widgets":["read"],"allWidgets":null,"parametersJsonScheme":null,"seoContent":{"title":[{"language":"de","value":""}],"metaTags":[],"h1":[{"language":"de","value":""}],"others":[{"name":"breadcrumbs","value":[{"language":"de","value":""}]}]},"contexts":[],"layoutModels":null,"acts":[{"parameters":[null],"chapter":{"format":"CPOActChapter","contexts":[],"subActs":[],"journeyStepUniqueKeys":null,"callToActions":null,"renderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[{"visualElementModelUniqueKey":"title_h3","label":"Recommendation Title","parameters":[{"name":"title","values":["{\"de\":\"Ihre persöhnliche Empfehlungen\",\"en\":\"Our reading suggestions for you\"}"]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[],"parameters":null}}]},{"visualElementModelUniqueKey":"rtux_content_list","label":"Blog List (via bx-hit return fields)","parameters":[{"name":"accessor","values":[""]},{"name":"content","values":["blog"]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[{"visualElementModelUniqueKey":"rtux_content_item","label":null,"parameters":[],"visualElement":null,"subRenderings":[{"parameters":null,"rendering":{"contexts":[],"layoutModels":[],"visualElements":[],"parameters":null}}]}],"parameters":null}}]},{"visualElementModelUniqueKey":"rtux_content_list","label":"Blog List (via GETTERS)","parameters":[{"name":"accessor","values":[""]},{"name":"content","values":[""]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[{"visualElementModelUniqueKey":"rtux_content_block","label":null,"parameters":[{"name":"link","values":["{\"de\":\"https://demo.bx-cloud.com/magazin/Nail%2520Design%253A%2520die%2520Tools%2520im%2520%25C3%259Cberblick?id=blog_1570\",\"fr\":\"https://demo.bx-cloud.com/magazin/Nail%2520Design%253A%2520die%2520Tools%2520im%2520%25C3%259Cberblick?id=blog_1570\",\"it\":\"https://demo.bx-cloud.com/magazin/Nail%2520Design%253A%2520die%2520Tools%2520im%2520%25C3%259Cberblick?id=blog_1570\",\"en\":\"https://demo.bx-cloud.com/magazin/Nail%2520Design%253A%2520die%2520Tools%2520im%2520%25C3%259Cberblick?id=blog_1570\"}"]},{"name":"image","values":["{\"de\":\"https://cdn.perfecthair.ch/media/image/d0/35/6c/Nagel-Design-Essentials-158f87643b6851.png\",\"fr\":\"https://cdn.perfecthair.ch/media/image/d0/35/6c/Nagel-Design-Essentials-158f87643b6851.png\",\"it\":\"https://cdn.perfecthair.ch/media/image/d0/35/6c/Nagel-Design-Essentials-158f87643b6851.png\",\"en\":\"https://cdn.perfecthair.ch/media/image/d0/35/6c/Nagel-Design-Essentials-158f87643b6851.png\"}"]},{"name":"title","values":["{\"de\":\"NAIL DESIGN: DIE TOOLS IM ÜBERBLICK\",\"fr\":\"FR NAIL DESIGN: DIE TOOLS IM ÜBERBLICK\",\"it\":\"IT NAIL DESIGN: DIE TOOLS IM ÜBERBLICK\",\"en\":\"EN NAIL DESIGN: DIE TOOLS IM ÜBERBLICK\"}"]},{"name":"description","values":["{\"de\":\"Ein schönes Nail Design zu kreieren ist gar nicht so schwer. Bloggerin Lea zeigt Ihnen, mit welchen Hilfsmitteln sie ihre schönen Nails Designs kreiert.\",\"fr\":\"Ein schönes Nail Design zu kreieren ist gar nicht so schwer. Bloggerin Lea zeigt Ihnen, mit welchen Hilfsmitteln sie ihre schönen Nails Designs kreiert.\",\"it\":\"Ein schönes Nail Design zu kreieren ist gar nicht so schwer. Bloggerin Lea zeigt Ihnen, mit welchen Hilfsmitteln sie ihre schönen Nails Designs kreiert.\",\"en\":\"Ein schönes Nail Design zu kreieren ist gar nicht so schwer. Bloggerin Lea zeigt Ihnen, mit welchen Hilfsmitteln sie ihre schönen Nails Designs kreiert.\"}"]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[],"parameters":null}}]},{"visualElementModelUniqueKey":"rtux_content_block","label":null,"parameters":[{"name":"link","values":["{\"de\":\"https://demo.bx-cloud.com/magazin/RE%252FSTART%2520COLOR%2520-%2520Farbschutz%2520der%2520Extraklasse?id=blog_5125\",\"fr\":\"https://demo.bx-cloud.com/magazin/RE%252FSTART%2520COLOR%2520-%2520Farbschutz%2520der%2520Extraklasse?id=blog_5125\",\"it\":\"https://demo.bx-cloud.com/magazin/RE%252FSTART%2520COLOR%2520-%2520Farbschutz%2520der%2520Extraklasse?id=blog_5125\",\"en\":\"https://demo.bx-cloud.com/magazin/RE%252FSTART%2520COLOR%2520-%2520Farbschutz%2520der%2520Extraklasse?id=blog_5125\"}"]},{"name":"image","values":["{\"de\":\"https://cdn.perfecthair.ch/media/image/c5/32/4a/RE_START-COLOR-Farbschutz-der-Extraklasse4kVU0YWRhrdX4.png\",\"fr\":\"https://cdn.perfecthair.ch/media/image/c5/32/4a/RE_START-COLOR-Farbschutz-der-Extraklasse4kVU0YWRhrdX4.png\",\"it\":\"https://cdn.perfecthair.ch/media/image/c5/32/4a/RE_START-COLOR-Farbschutz-der-Extraklasse4kVU0YWRhrdX4.png\",\"en\":\"https://cdn.perfecthair.ch/media/image/c5/32/4a/RE_START-COLOR-Farbschutz-der-Extraklasse4kVU0YWRhrdX4.png\"}"]},{"name":"title","values":["{\"de\":\"RE/START COLOR - FARBSCHUTZ DER EXTRAKLASSE\",\"fr\":\"RE/START COLOR - FARBSCHUTZ DER EXTRAKLASSE\",\"it\":\"RE/START COLOR - FARBSCHUTZ DER EXTRAKLASSE\",\"en\":\"RE/START COLOR - FARBSCHUTZ DER EXTRAKLASSE\"}"]},{"name":"description","values":["{\"de\":\"Jedes Haar hat eigene Bedürfnisse. Je nach Struktur und Beschaffenheit stehen andere Anliegen im Fokus. \",\"fr\":\"Jedes Haar hat eigene Bedürfnisse. Je nach Struktur und Beschaffenheit stehen andere Anliegen im Fokus. \",\"it\":\"Jedes Haar hat eigene Bedürfnisse. Je nach Struktur und Beschaffenheit stehen andere Anliegen im Fokus. \",\"en\":\"Jedes Haar hat eigene Bedürfnisse. Je nach Struktur und Beschaffenheit stehen andere Anliegen im Fokus. \"}"]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[],"parameters":null}}]},{"visualElementModelUniqueKey":"rtux_content_block","label":null,"parameters":[{"name":"link","values":["{\"de\":\"https://demo.bx-cloud.com/magazin/Beauty%2520ABC?id=blog_4330\",\"fr\":\"https://demo.bx-cloud.com/magazin/Beauty%2520ABC?id=blog_4330\",\"it\":\"https://demo.bx-cloud.com/magazin/Beauty%2520ABC?id=blog_4330\",\"en\":\"https://demo.bx-cloud.com/magazin/Beauty%2520ABC?id=blog_4330\"}"]},{"name":"image","values":["{\"de\":\"https://cdn.perfecthair.ch/media/image/13/48/79/Beauty-ABC.jpg\",\"fr\":\"https://cdn.perfecthair.ch/media/image/13/48/79/Beauty-ABC.jpg\",\"it\":\"https://cdn.perfecthair.ch/media/image/13/48/79/Beauty-ABC.jpg\",\"en\":\"https://cdn.perfecthair.ch/media/image/13/48/79/Beauty-ABC.jpg\"}"]},{"name":"title","values":["{\"de\":\"BEAUTY ABC\",\"fr\":\"FR BEAUTY ABC\",\"it\":\"IT BEAUTY ABC\",\"en\":\"EN BEAUTY ABC\"}"]},{"name":"description","values":["{\"de\":\"A wie Arganöl: Das exklusive Öl aus Marokko zählt zu den wertvollsten Pflanzenölen unserer Welt.\",\"fr\":\"A wie Arganöl: Das exklusive Öl aus Marokko zählt zu den wertvollsten Pflanzenölen unserer Welt.\",\"it\":\"A wie Arganöl: Das exklusive Öl aus Marokko zählt zu den wertvollsten Pflanzenölen unserer Welt.\",\"en\":\"A wie Arganöl: Das exklusive Öl aus Marokko zählt zu den wertvollsten Pflanzenölen unserer Welt.\"}"]}],"visualElement":null,"subRenderings":[{"parameters":[null],"rendering":{"contexts":[],"layoutModels":[],"visualElements":[],"parameters":null}}]}],"parameters":null}}]}],"parameters":null}}],"parameters":null}}],"parameters":[],"route":"narratives","reqParams":null,"$fromServer":true,"parentResource":null,"restangularCollection":false,"isSelected":true}]