06 Page Designer
06 Page Designer
Page Designer
Contents
1. Developing for Page Designer
1.1. What Is Page Designer?
1.2. Get the Page Designer Reference Examples
1.3. Page Designer Development Best Practices
1.4. Page Designer Developer Resources
2. Create Page and Component Types
2.1. Page Designer Meta Definition Files
2.2. Page-Level Custom Attributes
2.3. Initialize a Region with a Component Already Populated
2.4. Page Designer Script Files
2.5. Component Attribute Types and UI Controls
2.6. Component Attribute Types and Resolved Value Objects
2.7. Page Designer HTML
2.8. Page Type, Component Type, and Custom Attribute Editor IDs
2.9. Using Decorators with Page Designer Pages
2.10. Develop a Dynamic Page
2.10.1. Aspect Types
2.10.2. Components with Dynamic Attributes
2.10.3. Render a Dynamic Page
2.10.4. Best Practices for Developing a Dynamic Page
3. Create a Custom Cartridge for Page Designer UI Artifacts
3.1. Create Page Designer Localization Resource Bundles
3.2. Page Designer Thumbnail Images
4. Use Salesforce CMS Content with Page Designer
4.1. Get Access to Salesforce CMS
4.2. Connect Salesforce CMS to Page Designer
4.3. Develop a Component Type to Use CMS Content
4.4. Use Salesforce CMS Content to Configure a Component Attribute
5. Develop a Custom Attribute Editor
5.1. Why Implement a Custom Attribute Editor?
5.2. How Does a Custom Attribute Editor Work?
5.3. Custom Attribute in the Component Meta Definition File
5.4. Custom Attribute Editor Meta Definition File
5.5. Custom Attribute Editor Script File
5.6. Client-Side JavaScript and CSS for a Custom Attribute Editor
5.7. Custom Attribute Editor Events
5.8. Create a Breakout Custom Attribute Editor that Displays in a Modal Window
5.8.1. What Is a Breakout Editor?
5.8.2. Trigger Editor Meta Definition and Script Files
5.8.3. Breakout Editor Meta Definition and Script Files
5.8.4. Open and Close a Breakout Editor
5.8.5. Enable and Disable the Breakout Editor Apply Button
5.8.6. Trigger and Breakout Editor Client-Side UI Code
5.9. Use a Prebuilt Editor in a Custom Attribute Editor
6. Search Configuration for Page Designer Pages
6.1. Enable Search and Search Suggestions for Page Designer Pages
6.2. Enable Indexing for Attribute Content
6.3. Use SEO Page Meta Tag Rules for Dynamic Pages
7. Pages and Components as Content Assets
7.1. Pages and Components and OCAPI SHOP and DATA API
7.2. Page and Component Content Asset Attributes
7.3. Import and Export for Page Designer Pages and Components
8. Page Designer Caching
8.1. Page Caching
8.2. Page Type, Component Type, and Custom Attribute Editor Cache Times
9. Publish a Page Designer Page
9.1. Render Page Designer Pages from a Controller
9.2. Incorporate a Page Designer Page into the Storefront
9.3. Mock Component Placeholders
9.4. Render a JSON View of a Page Designer Page
Page Designer
Before merchants create Page Designer pages in the visual editor in Business Manager,
developers must create page types and component types for them to work
with.
Developers play an important role in implementing Page Designer. Developers work with the ecommerce marketing director to determine the pages, components, layouts, and assets required for the
storefront. The developer then creates and uploads custom cartridges that contain reusable page types, component types, and artifacts for the visual editor that help merchants quickly create and implement
custom pages.
To implement page types and component types, you must include a meta definition file and a script file for each page type and component type in a custom cartridge.
To localize page types and component types, or to display thumbnail images for them in the visual editor, create a custom cartridge that includes resource bundles for localization and thumbnail image files.
Upload the custom cartridge to the Business Manager site.
Use Salesforce CMS to manage all your content in a single repository. Merchants can use the CMS content on a Page Designer page. For example, you develop a component type that displays a headline
banner. You can create and manage different options for the content of the headline banner in Salesforce CMS. When merchants add the component type to a page, they select which content to use for the
headline banner from Salesforce CMS.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 1/23
11/10/21, 12:08 PM Page Designer
You can create a custom attribute editor for configuring component attributes. Merchants use the custom attribute editor when setting a value for the component attribute in the Business Manager visual
editor.
Pages and components are persisted in the database as content assets, but they aren't displayed in the content asset list in Business Manager and you can't edit them directly from Business Manager.
Generally, processes like replication and indexing work the same for pages and components as they do for content assets. But pages and components are different from content assets in some ways.
It’s important to understand how page caching works with Page Designer pages and the cache times for pages, components, and custom attribute editors.
Page Designer pages are rendered from a controller and incorporated into the storefront.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Page Designer is a B2C Commerce feature that supports standard development processes and tools for creating reusable page types and component types. Merchants can use a visual editor in Business
Manager to design, schedule, and publish custom pages in the storefront by dragging the page and component types. Merchants can use the same page and component types to create a variety of pages
independently, without going back to the developer for updates.
We provide example page types and component types to help you quickly get started using Page Designer.
In addition to following standard best practices for B2C Commerce development, follow these best practices that are specific to Page Designer.
The Commerce Cloud Developer Center (CCDC) includes webinars, demos, and details about features and functionality for Page Designer developers.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
1. The ecommerce marketing director meets with the developer to discuss the pages,
components, layouts, and assets required for the storefront.
2. The developer creates the reusable page types and component types that support the
ecommerce marketing director's requirements.
3. The developer uploads the custom cartridge that contains the page and component
types and another custom cartridge that contains supporting UI artifacts to a site.
4. The merchant uses the Page Designer visual editor in Business Manager to build
storefront pages using the page and component types that the developer has
implemented.
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Storefront Reference Architecture (SFRA) includes Page Designer page types and
component types optimized for use with SFRA. The latest version of SFRA is in
the
SFRA repository.
Page Designer reference cartridges for Site Genesis are in the SiteGenesis repository.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 2/23
11/10/21, 12:08 PM Page Designer
Note: On macOS, you can use the command-line unzip utility to expand the
files.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Do as much planning and gathering of requirements upfront as you can with the
merchant and ecommerce director before developing page types and component
types.
Create components that are self-contained so that any region where they are placed
can handle them as “black boxes.” To support self-containment, give each component
its
own default styling, although at times you might need to adjust the styling by
specifying custom render settings.
If you need to change the meta definition for a page or component type after the
merchant has already created instances of pages and components, be careful not to
make
incompatible changes. For example, if you change the type
value for a component attibute, you create an inconsistency between the component
type meta definition and the
component data in the database. In this case, it's
better to create a new component type and deprecate the old one.
For sites that share libraries, assign the same data and the same set of cartridges
with the same set of page and component types to each site. Sharing data and code
ensures
that there aren’t inconsistencies between meta definitions and data. For
example, you could have a page that was known in one site but not another, or two
sites that use the
same ID for different component types with different sets of
attributes, which would result in validation errors. Keep in mind that data and code
are shared using different
mechanisms that might have multiple relationships to
sites, as follows:
Table 1.
Page 1 library
Component 1 library
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Refer to the Page Designer CCDC Page for links to the Page
Designer resources.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Each page type and component type requires a JSON meta defintion file. A meta definition file for a page type describes the regions of the page where a merchant can place components. A meta defintion
file for a component type describes the attributes that a merchant defines when using the component type and can also define regions within the component type.
You can define custom page-level attributes for a page type. For example, you can define custom attributes for title, Image, and Description. Merchants can use those attributes to specify the image and text
that appears in the search results for a page.
Prepopulating a region with default components is a best practice that guides a merchant in creating a page. To specify that a region contains specific components by default, use the
default_component_constructors property in the meta definition file for a page type. You can also use this property in the meta definition file for a component type that includes a region. When the
merchant creates a page in the Visual Editor using the page type or component type, the default components are already populated in the region. The merchant can delete the components if necessary.
Each page type or component type requires a corresponding script file. The script file must have the same name as the type's meta definition file, but with a .js extension. For example, if the meta
definition file for a promotions page type is promopage.json, the script file is named promopage.js.
Each attribute in the meta definition file for a component type has a type assigned to it. The attribute's type determines how the merchant sets its value in the Page Designer visual editor. For example, an
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 3/23
11/10/21, 12:08 PM Page Designer
attribute of type file displays a file selection modal window that the merchant can use to browse the library files. An attribute of type enum displays a single select box where the merchant chooses one of
the allowed values.
The content attributes available from the context object, also known as the content dictionary, are defined in a map with the attribute IDs as the keys and the resolved values as values. A resolved value is
a value that has been converted to B2C Commerce API objects when necessary. For example, for an attribute of type product, the value of the attribute (the product SKU) is converted to a
dw.catalog.Product object instance. For some attributes, conversion isn't necessary. For example, strings can be stored as is. The following table lists the content attribute types and their
corresponding B2C Commerce API objects.
The render function of a page type creates the page's HTML markup. Typically, the page type's render function calls an ISML template that uses PageMgr.renderRegion() to render each region of
the page.
A page type, component type, or custom attribute editor ID is a combination of the subdirectory (if any) where the meta definition file and script file are located and the file name without the extension.
Separate the levels of the subdirectory and the file name with periods. For example, for a page type named homepage with a meta definition file and script file located directly under
cartridge/experience/pages, the page type ID is homepage. If the meta definition file and script file for homepage are located in a subdirectory storefront/campaigns under
cartridge/experience/pages, the page type ID is storefront.campaigns.homepage.
You can implement various strategies for using decorators with Page Designer pages. For example, you can write the script file for a page type so that you can pass in a custom decorator as a parameter
when the page is rendered, or fall back to a default decorator defined in the script. You can also write the controller that renders the page so that a different decorator is used based on the value of a certain
condition.
A dynamic page uses one or more dynamic attributes passed to the page at runtime to determine what content to display in the storefront. The typical use case is the developer creates an aspect type for a
particular business use, for example a Product List or Product Details page. The developer assigns the aspect type to a page type that defines the layout for the page. The merchant uses the page type to
create a template Product List or Product Detail page and assigns the template page to one or more categories. Whenever a Product List or Product Detail page is required in the storefront for one of the
assigned categories, the template page is displayed. The content of the template page is populated based on the category dynamic attribute.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Put the meta definition file in one of the following directories of the custom cartridge, or
any arbitrary subdirectory within these directories:
Page types:
<your_cartridge>/cartridge/experience/pages
Component types:
<your_cartridge>/cartridge/experience/components
The meta definition file name can include only alphanumeric or underscore characters. If you
put the meta definition file into a subdirectory within the
/experience/pages or
/experience/components
directories, the names of the levels in the subdirectory must also use only alphanumeric or
underscore characters.
To view schema files that describe the JSON formatting for the meta definition file, see
Page Designer
JSON Schemas.
promopage.json
"name":"Promopage",
"region_definitions":[
"id":"header",
"name":"Name",
"max_components":1
},
"id":"main",
"name":"Main",
"component_type_exclusions":[
{"type_id":"banner"}
},
"id":"footer",
"name":"Footer",
"max_components":1
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 4/23
11/10/21, 12:08 PM Page Designer
This example banner component type meta definition file, named
banner.json, defines four attributes that the merchant can set: the
image file, its alt text, its size, and an attribute
named Magic Unicorns that lets the
merchant select which unicorn to display on the banner. The Magic Unicorns attribute is
configured using a custom UI control,
com.sfcc.magical. In the Page Designer
visual editor, the attributes appear in groups. For example, the four attributes defined in
this file appear in the visual editor in a group
labeled Banner Image
Configuration.
The default_value setting for an attribute is used only for rendering the
page in the storefront or previewing in the visual editor. The default_value
is not shown as preselected
in the visual editor that the merchant uses to configure the
component. Rendering behavior based on settings for required and
default_value is as follows:
banner.json
"name": "Banner",
"group": "content",
"attribute_definition_groups": [
"id": "image",
"description": "You can define the image file, size and alt text for the banner image.",
"attribute_definitions": [
"id": "image",
"type": "file",
"required": true
},
"id": "alt",
"type": "string",
"required": false
},
"id": "size",
"name": "Size",
"type": "enum",
"values": [
"small",
"medium",
"large"
],
"required": true,
"default_value": "medium"
},
"id": "magic",
"type": "custom",
"required": true,
"editor_definition": {
"type": "com.sfcc.magical",
"configuration": {
"options": {
"config": [
"Auris",
"Chant",
"Elmas",
"Majesty",
"Moriba",
"Mystery",
"Mystic",
"Snowflake",
"Solstice",
"Sunshine"
],
"region_definitions": []
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 5/23
11/10/21, 12:08 PM Page Designer
3column.json
"group": "layouts",
"attribute_definition_groups": [],
"region_definitions": [
"id":"column1",
"name":"Column 1",
"max_components":1
},
"id":"column2",
"name":"Column 2",
"max_components":1
},
"id":"column3",
"name":"Column 3",
"max_components":1
Related concepts
Related reference
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Define the page-level attributes in the meta definition file for the page type. This
example shows three attributes defined for a Search Results Title, Search Results Image,
and Search
Results Description.
promopage.json
"name": "Promopage",
"attribute_definition_groups": [{
"id": "search",
"description": "Define the title, image, and description returned in search results for the page.",
"attribute_definitions": [{
"id": "title",
"type": "text",
"required": false
},
"id": "image",
"type": "file",
"required": false
},
"id": "description",
"type": "text",
"required": false,
],
"region_definitions": [{
"id": "header",
"name": "Name",
"max_components": 1
},
"id": "main",
"name": "Main",
"component_type_exclusions": [{
"type_id": "banner"
}]
},
"id": "footer",
"name": "Footer",
"max_components": 1
}]
Related concepts
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
The following example specifies that the main region of the page is prepopulated with a
default component. The component has id commerce_layouts.productDetail and
name
Product Detail Layout.
"region_definitions":[
"id":"top",
"name":"Top Region",
},
"id":"main",
"name":"Main Region",
"default_component_constructors": [
],
},
"id":"bottom",
"name":"Bottom Region",
],
"supported_aspect_types": ["pdp"]
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
The script file name can include only alphanumeric or underscore characters. Put the
script file at the same location as its corresponding meta definition file. For example,
for a
component type named headlinebanner, you could include the meta definition file
and the script file at the following locations :
mycartridge/cartridge/experience/components/assets/headlinebanner.json
mycartridge/cartridge/experience/components/assets/headlinebanner.js
The script file must include a render function that returns the markup
for the page. You can assemble the markup using any process you want, as long as the
result is a string. In
many cases, the render function calls an ISML
template to which it passes information about the page or component type and its
content. If you use an ISML template, you must use
the dw.util.Template
API to render the markup from the template. Do not use dw.template.ISML
because it doesn't return a string, and it writes the markup to the response
stream
right away.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 7/23
11/10/21, 12:08 PM Page Designer
context.renderParameters—Parameters passed to
PageMgr.renderPage(pageID, parameters)
promopage.js
'use strict';
/**
*/
// add paramters to model as required for rendering based on the given context (dw.experience.PageScriptContext):
// * context.page (dw.experience.Page)
// * context.renderParameters (String)
// * context.content (dw.util.Map)
};
In this banner script file, named banner.js, the context object that
is passed to the render function is of type
dw.experience.ComponentScriptContext. It provides access to:
banner.js
'use strict';
/**
*/
// add paramters to model as required for rendering based on the given context (dw.experience.ComponentScriptContext):
// * context.component (dw.experience.Component)
// * context.content (dw.util.Map)
};
Related concepts
Related reference
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
This table describes the type options for component attributes and how those options
are displayed in the Page Designer visual editor.
cms_record Record from the Salesforce CMS User is presented with a modal window to select the CMS record. After
the user selects the CMS record, the edit panel
(Content Management System) displays the UI controls
necessary to configure the attributes of the slected CMS record.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 8/23
11/10/21, 12:08 PM Page Designer
image String representing a configurable Image picker that lets users select an image and specify a focal
point on that image. The image dimensions are also
image JSON stored and can be
accessed, along with the image name and focal point, using the Image API
markup String representing HTML markup A rich text editor that allows semantic formatting options to produce
HTML markup
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
category dw.catalog.Category
cms_record dw.experience.CMSRecord
custom dw.util.Map
file dw.content.MediaFile
image dw.experience.image.Image
page dw.experience.Page
product dw.catalog.Product
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
In this example, a page calls an ISML template. This ISML template renders three regions:
header, main, and footer.
promopage.isml
<html>
...
...
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce/t… 9/23
11/10/21, 12:08 PM Page Designer
...
...
</html>
banner.isml
...
<img width="<!-- calculate it in your component controller using ${pdict.content.size} -->" src="../topic/com.demandware.dochelp/con
<!--
// if the 'assets.banner' component type had a region 'foobar' we could render it here
-->
...
As each region and component is rendered, Page Designer creates an HTML element to wrap
the content. You can specify which HTML element to use as the wrapper and which
attributes to assign to the wrapper using the
dw.experience.RegionRenderSettings and
dw.experience.ComponentRenderSettings APIs. For more information,
see:
RegionRenderSettings API
ComponentRenderSettings API
By default, the HTML wrapper for regions and components is div. The
default CSS class for regions is experience-region
experience-<region_definition_id>. The
default
CSS class for components is experience-component
experience-<componenttype_id>.
For example, for a region with id my_region and three components, two of type
my_component_type_1 and one of type my_component_type_2, the default HTML wrapper is:
</div>
</div>
</div>
</div>
In some cases, you want a component to have a different style depending on which region
contains the component. For example, you define a component type for a product tile that
uses default render settings. You define another component type for a carousel, which is
a one-region component that scrolls through a number of other components. When the
product tile component appears in the carousel, you want it to use different styling
specific to the carousel.
You could specify that the HTML wrapper for the carousel uses a custom CSS class called
item for the first and second components. Then specify a
different CSS class, item
active, for the third component, to
distinguish it as the active component in the carousel. Here's the HTML wrapper for the
carousel.
<div class="carousel-inner">
<div class="item">
</div>
<div class="item">
</div>
</div>
</div>
Here's the code to set the custom render settings for the carousel. You could include
this code in the render function of the script file for the component.
Note: The Page Designer reference implementation available in GitHub includes helper
functionality to streamline this code.
carouselRenderSettings.setTagName("div");
carouselRenderSettings.setAttributes({"class" : "carousel-inner"});
defaultCarouselComponentRenderSettings.setTagName("div");
defaultCarouselComponentRenderSettings.setAttributes({"class" : "item"});
carouselRenderSettings.setDefaultComponentRenderSettings(defaultCarouselComponentRenderSettings);
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 10/23
11/10/21, 12:08 PM Page Designer
activeCarouselComponentRenderSettings.setTagName("div");
carouselRenderSettings.setComponentRenderSettings(activeCarouselComponent, activeCarouselComponentRenderSettings);
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
2.8. Page Type, Component Type, and Custom Attribute Editor IDs
A page type, component type, or custom attribute editor ID is a combination of the
subdirectory (if any) where the meta definition file and script file are located and the
file name without
the extension. Separate the levels of the subdirectory and the file name
with periods. For example, for a page type named homepage with a meta
definition file and script file located
directly under
cartridge/experience/pages, the page type ID is
homepage. If the meta definition file and script file for
homepage are located in a subdirectory
storefront/campaigns under
cartridge/experience/pages, the page type ID is
storefront.campaigns.homepage.
mycartridge/cartridge/experience/components/assets/headlinebanner.json assets.headlinebanner
mycartridge/cartridge/experience/components/assets/banners/headlinebanner.json assets.banners.headlinebanner
mycartridge/cartridge/experience/pages/promopage.json promopage
mycartridge/cartridge/experience/pages/promotions/promopage.json promotions.promopage
mycartridge/cartridge/experience/editors/com/sfcc/magical.json com.sfcc.magical
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
...
...
...
When pages are displayed in the visual editor as the merchant is creating them, the
default decorator defined in the script file is used. To optimize the experience of
creating pages for
the merchants, you could define the
DEFAULT_DECORATOR constant in the script to point to a lightweight
decorator that loads quickly in the visual editor. But then when the controller
renders
the page in the storefront, you could pass in the location of the full decorator to use
to display the pages.
You can also choose which decorator to use based on the state of a condition. For
example, in the following snippet from a storefront controller, the decorator at
decoration/ajax is
used if the format of the page is based on
AJAX (Asynchronous Javascript and XML), but the decorator at
decoration/full is used if the page is not based on AJAX.
exports.Show = function () {
...
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 11/23
11/10/21, 12:08 PM Page Designer
...
var params = {
};
response.writer.print(PageMgr.renderPage(page.ID, JSON.stringify(params)));
...
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
For an example of how a merchant implements a Product List or Product Details template,
see Create a Product List or Product Detail Page Template.
Aspect Types
To implement a dynamic page, create an aspect type meta definition file that defines the attributes required for a particular business use. The aspect type meta definition file also defines the business object
type that the merchant can bind to the page when the page is created. In the meta definition file for the page type, specify which aspect types are supported for the page type.
A component attribute can include a dynamic_lookup property. The dynamic_lookup property specifies an attribute of the aspect. The component attribute gets its value from the aspect attribute
specified.
Aspect attributes are passed to the page through the Page.renderPage() method that takes aspectAttributes.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
To view the schema file that describes the JSON formatting for the aspect type meta
definition file, see Page Designer JSON Schemas.
Put the aspect type meta definition file in the following directory of the custom
cartridge, or any arbitrary subdirectory within this directory:
<your_cartridge>/cartridge/experience/aspects
The following examples show aspect meta definition files for a Product List page and a
Product Detail page. The Product List page aspect type has one attribute for category
and
supports the object type category, which the merchant assigns during page creation.
The Product Detail page aspect type has two attributes, one for product and one for
category. The
Product Detail page also supports the object type category, which the
merchant assigns during page creation. All products in the assigned categories use the
Product Detail page.
plp.json
"attribute_definitions": [
"id": "category",
"name": "Category",
"type": "category"
],
"supported_object_types": [
"category"
pdp.json
"attribute_definitions": [
"id": "product",
"name": "Product",
"type": "product",
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 12/23
11/10/21, 12:08 PM Page Designer
type : product ,
"required": true
},
"id": "breadcrumb_category",
"description": "The optional category context of the pdp, for breadcrumb purposes.",
"type": "category",
"required": false
],
"supported_object_types": [
"category"
Specify the supported aspect types in the page definition file for the page type, as in
the following example. Because this page type declares support for the
plp aspect type, the page
requires the category attribute defined
in the plp.json meta definition file. Category is the dynamic attribute
that the controller or script uses to render the page in the storefront.
plplayout.json
"description": "A layout for a product list page with a region to contain a product grid component.",
"supported_aspect_types": [
"plp"
],
"region_definitions": [{
"id": "main",
}]
You can create a page type that supports more than one aspect type. During page creation,
the merchant selects which aspect type to use for the page by selecting a Page Purpose
in
the page creation wizard.
dynamiclayout.json
"description": "A generic layout whose region can use any kind of component.",
"supported_aspect_types": [
"plp",
"pdp"
],
"region_definitions": [{
"id": "main",
}]
Related concepts
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
productgrid.json
"group": "commerce_layouts",
"attribute_definition_groups": [
"id": "productList",
"name": "Settings",
"attribute_definitions": [
"id": "category",
"name": "Category",
"type": "category",
"required": false,
"dynamic_lookup":{
"aspect_attribute_alias": "category"
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 13/23
11/10/21, 12:08 PM Page Designer
]
},
"region_definitions": [...]
In the Visual Editor, the merchant can override the category that the page is using and
assign a different category to the component. For example, in the SFRA reference
implementation, the dynamic banner component uses the category value assigned to the page by
default. The component uses the banner image and banner text assigned in
Business Manager for
the category assigned to the page.
The merchant can edit the category value and assign it to something other than the value the
page is using. For example, the merchant can specify that the banner component uses
the
category mens-clothing regardless of the category assigned to the page.
As the SFRA reference component is implemented, the merchant can also override attributes of
the component separately from the dynamic category attribute. For example, the
merchant can
specify that regardless of the category, the banner always displays an image for women's shoes
and handbags.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 14/23
11/10/21, 12:08 PM Page Designer
Related concepts
Aspect Types
Render a Dynamic Page
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
The following code snippet passes aspect attributes to the page during rendering:
aspectAttributes.put("category", category);
The following code snippet checks to see if a page is assigned to the given category for
a given aspect type and returns that page. If there is no page assigned, the code walks
up the
category hierarchy until it either finds a category with the page assigned or it
reaches root. If no page is found even for root, it returns null.
Related concepts
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Be specific when naming a component, clearly indicating what kind of page the
component is intended for. For example, name a component intended for a Product
Detail page,
Product Detail Grid. If the merchant uses a component
that has attributes not specified by the aspect type assigned to the page, the
component doesn't render correctly.
By naming the components carefully, you can help
merchants create pages with the appropriate components.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 15/23
11/10/21, 12:08 PM Page Designer
Be careful when creating a page type that supports more than one aspect type.
Merchants must complete the extra and potentially confusing step of selecting a page
type
purpose during creation. Also, a page type generic enough to accommodate more
than one aspect type can make only limited use of prepopulated components, providing
the
merchant less guidance during page design.
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
A resource bundle contains the localized names and descriptions for each page type, component type, and component type group that you want to localize. Including a resource bundle is optional. If you
don’t provide them, the visual editor uses information in the meta definition files.
In the Page Designer visual editor, thumbnail images assist the merchant in determining which page or component to select. If you don't provide thumbnail images, generic images are displayed.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Each page type, component type group, and component type requires a separate resource
bundle.
<componenttype/pagetype/componenttypegroup>
_<locale>.properties
Put the resource bundles for page types and component types in this location in the
cartridge:
<your_cartridge>/cartridge/templates/resources/experience/pages
<your_cartridge>/cartridge/templates/resources/experience/components
Put resource bundles for component type groups within a componentgroup subdirectory:
<your_cartridge>/cartridge/templates/resources/experience/componentgroups
If the page type and component type files are located in a subdirectory of the
../experience/pages or
../experience/components directories, the resource bundles must
be
located in a corresponding subdirectory of the resources
directory.
Table 1.
mycartridge/cartridge/experience/components/banners/headlinebanner.json myBMcartridge/cartridge/templates/resources/experience/compone
mycartridge/cartridge/experience/pages/promopage.json myBMcartridge/cartridge/templates/resources/experience/pages/p
mycartridge/cartridge/experience/pages/promotions/promopage.json myBMcartridge/cartridge/templates/resources/experience/pages/p
content myBMcartrige/cartridge/templates/resources/experience/componen
promopage_en.properties
name=Promotional Page
region.header.name=Header
region.main.name=Main
region.footer.name=Footer
banner_en.properties
name=Banner
description=A banner that allows to configure which image to show in a sizable manner.
attribute_definition_group.image.description=You can define the image file, size and alt text for the banner image.
attribute_definition.image.name=Image
attribute_definition.size.name=Size
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 16/23
11/10/21, 12:08 PM Page Designer
content_en.properties
name=Content
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
The file name for a thumbnail images (without the extension) must match the
name of the respective page type or component type, for example,
promopage.png or
promopage.svg. Page
Designer doesn't support a different thumbnail image for different locales.
<your_cartridge>/cartridge/static/default/images/experience/pages/<subdirectory>/<id>
The
optional <subdirectory> must match the subdirectory where the
pages are in the ../experience/pages directory.
For example
if the page type is located in
mycartridge/cartridge/experience/pages/promotions/promopage.json,
the image file must be located
here:
myBMcartridge/cartridge/static/default/images/experience/pages/promotions/promopage.png
<your_cartridge>/cartridge/static/default/experience/components/<sudirectory>/<id>
mycartridge/cartridge/static/default/experience/components/banners/headlinebanner.png
Related concepts
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
To use CMS content with Page Designer components, make sure your Salesforce org includes Salesforce CMS.
Connect your B2C Commerce instance to a CMS channel and assign the channel to your site library.
Configure the component attribute by selecting the Salesforce CMS content and then configuring the attributes for that content.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 17/23
11/10/21, 12:08 PM Page Designer
1. Open a support ticket and request a trust relationship between your Salesforce
org and your B2C Commerce instance.
2. In Salesforce CMS, add a CMS workspace to host the Page Designer content or use
an existing CMS workspace.
For information about creating CMS workspaces, see Create a CMS Workspace in
Salesforce CMS.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 18/23
11/10/21, 12:08 PM Page Designer
5. In B2C Commerce Business Manager, go to Administration > Sites > Content Libraries > site
> General. Scroll to the bottom and assign the CMS channel to your site
library.
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
For example, the following meta defintion file and script files for component
type CMS Headline Banner use a Headline Content attribute of type
cms_record, with
content_type news.
cmsheadlinebanner.json
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 19/23
11/10/21, 12:08 PM Page Designer
{
"description": "Image, text overlay from CMS that links user to a B2C target using the markup editor",
"group": "assets",
"attribute_definition_groups": [{
"id": "headlineContent",
"attribute_definitions": [{
"id": "cmsItem",
"type": "cms_record",
"required": true,
"editor_definition": {
"content_type": "news"
}]
},
"id": "calltoaction",
"attribute_definitions": [{
"id": "ctaTitle",
"type": "string",
"required": true
},
"id": "ctaLink",
"type": "url",
"required": true
],
"region_definitions": []
cmsheadlinebanner.js
'use strict';
/**
*/
module.exports.render = function(context) {
if (content.cmsItem) {
model.bannerTitle = content.cmsItem.attributes.title;
model.bannerCopy = content.cmsItem.attributes.body;
if (content.cmsItem.attributes.bannerImage) {
model.bannerImg = {
src: {
},
alt: content.cmsItem.attributes.excerpt
};
model.callToAction = {
title: content.ctaTitle,
link: content.ctaLink
};
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 20/23
11/10/21, 12:08 PM Page Designer
When you select CMS content for a component attribute, the CMS content is copied
into the page. If the original content in the CMS is updated, the changes don't
automatically appear
in the component. You must reconfigure the component attribute and
select the content again to get the updated content.
1. Add the component that uses Salesforce CMS content to the page.
In this example, the CMS Headline Banner component type uses CMS content to
configure the Headline Content attribute.
3. Choose the CMS content you want to use and click Select.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 21/23
11/10/21, 12:08 PM Page Designer
The CMS content is copied to the page. Any attributes for the CMS
content that require configuration are presented in the editing pane. The CMS
content for the Headline
Banner in the example requires that you enter a Title,
Body, and Banner Image.
Related tasks
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
When you create a component type for Page Designer, you specify attributes that the merchant can set. For example, you could create a headline banner component type with an attribute named Image.
When merchants use the headline banner component type on a page, they must configure the Image attribute to select the image to display. The type value that you assign to the attribute in the
component’s meta definition file determines the UI control (for example, a check box or file picker) that the merchant uses to configure the attribute.
A custom attribute editor uses a meta definition file, script, and JavaScript and CSS resources to implement an editor that operates within a self-contained environment on the client side. The merchant uses
the custom attribute editor in the Page Designer visual editor to configure a value for the attribute.
In the meta definition file for any standard component type, set the type of the attribute for which you want to use a custom attribute editor to custom and include an editor_definition element for the
attribute. The editor_definition includes the custom attribute editor ID and optionally any configuration information that you want to pass to the custom attribute editor.
The meta definition file for a custom attribute editor references the JavaScript and CSS resources that the custom attribute editor requires.
Each custom attribute editor requires a script file. The script file has the same name as the corresponding meta definition file but with a .js extension. For example, if the meta definition file for the control is
magical.json, name the script magical.js.
Put the client-side JavaScript files and CSS resources required to run the custom attribute editor in the static/default directory of the custom cartridge at a location that corresponds to the location of
the meta definition file and script file for the editor.
Each custom attribute editor is wrapped in a host component that contains an HTML iframe element. The iframe encapsulates the code and styling of the editor and represents a self-contained sandbox
environment in which the editor runs so that different custom attribute editors on the same page don't interfere with each other. The host and the custom attribute editor in the iframe communicate by
passing events back and forth on a special messaging channel.
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 22/23
11/10/21, 12:08 PM Page Designer
Create a custom attribute editor sized to fit your content with the breakout custom attribute feature.
Create custom attribute editors faster and more efficiently with prebuilt attribute editors. You can use the prebuilt editors as building blocks when you create custom attribute editors.
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
Page Designer provides some preconfigured options for type. For example,
if you assign the type file to an attribute, the Page Designer Visual
Editor presents the merchant with a
file picker UI control for selecting which file to
use. If you assign the type boolean, the merchant is presented with a
checkbox to configure the attribute. The type enum presents the
merchant with a list to select a value from.
If none of the preconfigured Page Designer UI controls are appropriate for your
situation, you can create your own custom attribute editor. For example, you might want
a custom
attribute editor to let merchants select store locations on a map or choose a
color for the text or background. Or, you want to let merchants place a Favorite icon on
a product tile or
select which Shop Now button to use.
A custom attribute editor doesn’t conflict with the platform code for Page Designer, and
you can create more than one custom attribute editor for a single component type.
Related concepts
Related reference
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
In the meta definition file for the component type, define the attribute's type as
custom. If information is passed to the custom attribute editor,
include that information in an
editor_definition element for the
attribute. In the meta definition file for the custom attribute editor, list the CSS and
JavaScript resources that the custom attribute editor requires.
You can optionally add
server-side logic or resources to initialize the custom attribute editor in the script
file for the custom attribute editor. You include the meta definition file and script
file for the custom attribute editor, along with the JavaScript and CSS resources, in a
custom cartridge assigned to the Business Manager site.
On the client side, each custom attribute editor is wrapped in a host component that
contains an HTML <iframe> element. The iframe encapsulates the code
and style of the editor
and represents a self-contained sandbox environment in which the
editor runs so that different custom attribute editors on the same page don't interfere
with each other.
The host and the custom attribute editor in the iframe communicate with each other on a
dedicated communication channel. Page Designer adds some management code to the iframe
that includes a subscribe method and an emit method
that send predefined events with serializable payloads back and forth between the host
and the editor.
For information about the messaging channel implemented for Page Designer custom
attribute editors, see Channel Messaging.
Related concepts
Related reference
© Copyright 2000-2021, salesforce.com inc. All rights reserved. Various trademarks held by their respective owners. Show URL Submit Feedback Privacy Policy
https://documentation.b2c.commercecloud.salesforce.com/DOC1/advanced/print.jsp?topic=/com.demandware.dochelp/content/b2c_commerce… 23/23