A Page Designer component or page type is a meta JSON and a render script with the same name. Intellij SFCC types the render script from the JSON and completes the JSON from your cartridges
group and type_id complete from your cartridges and Cmd+Click on a type ID opens the component's JSON or script. The render script types context.content from the attributes of its meta JSONBefore you start
| Needs | Why |
|---|---|
Files in cartridge/experience | Page Designer files are recognized by folder: experience/components, experience/pages, experience/editors and experience/aspects |
| A linked cartridge | Render scripts are typed only in linked cartridges, see Cartridges & Modules |
| A valid license or trial | Completion and Cmd+Click in the meta JSON are paid features, see Purchase & License |
Typed render scripts
The parameters of a function named render in a script under experience/components or experience/pages are typed, for example module.exports.render = function (context, modelIn) { ... }
| Parameter | In a component script | In a page script |
|---|---|---|
First, context | dw.experience.ComponentScriptContext | dw.experience.PageScriptContext |
Second, modelIn | dw.util.Map | dw.util.Map |
context.component, context.componentRenderSettings and the other context members complete without JSDoc
context.content
context.content gets a member for each attribute in the attribute_definitions of the meta JSON next to the script, heroBanner.json for heroBanner.js, typed from the attribute's type
{
"name": "Hero Banner",
"group": "commerce_assets",
"region_definitions": [],
"attribute_definition_groups": [
{
"id": "content",
"name": "Content",
"attribute_definitions": [
{ "id": "image", "type": "image" },
{ "id": "heading", "type": "string" },
{ "id": "categoryLink", "type": "category" }
]
}
]
}var Template = require('dw/util/Template');
var HashMap = require('dw/util/HashMap');
module.exports.render = function (context, modelIn) {
var model = modelIn || new HashMap();
model.heading = context.content.heading; // string
model.image = context.content.image; // dw.experience.image.Image
model.category = context.content.categoryLink; // dw.catalog.Category
return new Template('experience/components/commerce_assets/heroBanner').render(model).text;
};Attribute type | Member type |
|---|---|
string | string |
boolean | boolean |
integer | int |
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 and dw.catalog.Variant |
Any other type, such as text, markup, enum or url | string |
Page scripts read their page type JSON the same way. context.getContent() stays dw.util.Map, only the content property is typed
Complete the meta JSON
Press Ctrl+Space in an empty string value:
| Value | Completes | Each item shows |
|---|---|---|
group | Groups declared in any Page Designer JSON | The group name |
type_id, for example in component_type_inclusions | Component type IDs from experience/components, as a dotted path such as commerce_assets.heroBanner | components and the cartridge |
type inside editor_definition | Custom editor type IDs from experience/editors | editors and the cartridge |
scripts and styles arrays | JS and CSS files from your cartridges' static folders, as a path below the locale folder such as /js/editors/colorPicker.js | The cartridge |
With a site scope selected, static files from that site's cartridges come first
Go to components and editors
Cmd+Click (Ctrl+Click) on a value in a meta JSON opens what it names
| Value | Opens |
|---|---|
type_id in component_type_inclusions, component_type_exclusions or default_component_constructors | The component's JSON and script, the IDE asks which |
type inside editor_definition | The custom editor's JSON and script |
group | Every file that declares that group |
An entry of scripts or styles in a custom editor under experience/editors | The static file. An http or https URL opens in the browser |
Above a page or component type, the used by N pages or used by N components lens opens the library content that uses it, see Code Vision
Schemas
Each meta JSON is validated against a bundled schema picked by folder: Salesforce B2C Page Designer - Pages, Components, Aspects or Editors. Keys such as region_definitions complete, and a missing required key is a warning, see XML & JSON Validation
Troubleshooting
| Symptom | What to do |
|---|---|
context isn't typed in a render script | The function must be named render and the script must be under experience/components or experience/pages of a linked cartridge |
context.content. lists no attributes | The meta JSON must have the script's name and sit in the same folder, and every attribute needs an id and a type |
type_id lists nothing | The component JSON files must be under cartridge/experience/components of a linked cartridge |
Cmd+Click on type_id does nothing | It navigates only inside component_type_inclusions, component_type_exclusions or default_component_constructors |
| No completion in the meta JSON | Check that your license or trial is active, see Purchase & License |