Skip to Content

Page Designer

Typed render scripts, context.content from the meta JSON, and completion and navigation in Page Designer component and page JSON

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

In Page Designer meta JSON, 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 JSON

Before you start

NeedsWhy
Files in cartridge/experiencePage Designer files are recognized by folder: experience/components, experience/pages, experience/editors and experience/aspects
A linked cartridgeRender scripts are typed only in linked cartridges, see Cartridges & Modules
A valid license or trialCompletion 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) { ... }

ParameterIn a component scriptIn a page script
First, contextdw.experience.ComponentScriptContextdw.experience.PageScriptContext
Second, modelIndw.util.Mapdw.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

cartridge/experience/components/commerce_assets/heroBanner.json
{
  "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" }
      ]
    }
  ]
}
cartridge/experience/components/commerce_assets/heroBanner.js
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 typeMember type
stringstring
booleanboolean
integerint
categorydw.catalog.Category
cms_recorddw.experience.CMSRecord
customdw.util.Map
filedw.content.MediaFile
imagedw.experience.image.Image
pagedw.experience.Page
productdw.catalog.Product and dw.catalog.Variant
Any other type, such as text, markup, enum or urlstring

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:

ValueCompletesEach item shows
groupGroups declared in any Page Designer JSONThe group name
type_id, for example in component_type_inclusionsComponent type IDs from experience/components, as a dotted path such as commerce_assets.heroBannercomponents and the cartridge
type inside editor_definitionCustom editor type IDs from experience/editorseditors and the cartridge
scripts and styles arraysJS and CSS files from your cartridges' static folders, as a path below the locale folder such as /js/editors/colorPicker.jsThe 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

ValueOpens
type_id in component_type_inclusions, component_type_exclusions or default_component_constructorsThe component's JSON and script, the IDE asks which
type inside editor_definitionThe custom editor's JSON and script
groupEvery file that declares that group
An entry of scripts or styles in a custom editor under experience/editorsThe 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

SymptomWhat to do
context isn't typed in a render scriptThe function must be named render and the script must be under experience/components or experience/pages of a linked cartridge
context.content. lists no attributesThe 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 nothingThe component JSON files must be under cartridge/experience/components of a linked cartridge
Cmd+Click on type_id does nothingIt navigates only inside component_type_inclusions, component_type_exclusions or default_component_constructors
No completion in the meta JSONCheck that your license or trial is active, see Purchase & License

On this page