Skip to content

Commit 2862fe5

Browse files
Enhance page designer component creator (#252)
After testing the skill I was habing a lot of problems getting a working component right with cursor, so I've enhanced the skill for the component creation in order to make sure all creating steps where followed as it should.
1 parent 8bfeca8 commit 2862fe5

1 file changed

Lines changed: 40 additions & 5 deletions

File tree

  • skills/b2c/skills/b2c-page-designer

skills/b2c/skills/b2c-page-designer/SKILL.md

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: b2c-page-designer
3-
description: Create Page Designer pages and components in B2C Commerce. Use when building visual merchandising tools, content slots, or experience API integrations. Covers page types, component types, regions, and attribute definitions.
3+
description: Create Page Designer pages and components in B2C Commerce. Use when building visual merchandising tools, content slots, or experience API integrations. Covers page types, component types, regions, attribute definitions, component type ID and subfolders, enum and custom/color attribute pitfalls, and troubleshooting when a component does not appear in the editor.
44
---
55

66
# Page Designer Skill
@@ -37,7 +37,9 @@ Page Designer files are in the cartridge's `experience` directory:
3737
banner.isml # Component template
3838
```
3939

40-
**Naming:** The `.json` and `.js` files must have matching names.
40+
**Naming:** The `.json` and `.js` files must have matching names. Use only **alphanumeric** or **underscore** in file names and in any subdirectory names under `experience/pages` or `experience/components`.
41+
42+
**Component types in subfolders:** You can put component meta and script in a subdirectory (e.g. `experience/components/assets/`). The **component type ID** is then the path with dots: `assets.hero_image_block`. The template path under `templates/default/` must mirror that path (e.g. `templates/default/experience/components/assets/hero_image_block.isml`), and the script must call `Template('experience/components/assets/hero_image_block')` so the path matches. Stored ID is `component.{component_type_id}`; total length must not exceed 256 characters.
4143

4244
## Page Types
4345

@@ -119,6 +121,7 @@ module.exports.render = function (context) {
119121
"name": "Banner",
120122
"description": "Promotional banner with image and CTA",
121123
"group": "content",
124+
"region_definitions": [],
122125
"attribute_definition_groups": [
123126
{
124127
"id": "image",
@@ -188,6 +191,8 @@ module.exports.render = function (context) {
188191
}
189192
```
190193

194+
**Component meta:** Always include `region_definitions`. Use `[]` when the component has no nested regions (no slots for other components).
195+
191196
### Component Script (components/banner.js)
192197

193198
```javascript
@@ -215,6 +220,19 @@ module.exports.render = function (context) {
215220
};
216221
```
217222

223+
**Template path:** The path passed to `Template(...)` must match the template path under `templates/default/`. If the component lives in a subfolder (e.g. `experience/components/assets/hero_image_block`), use `Template('experience/components/assets/hero_image_block')` and place the ISML at `templates/default/experience/components/assets/hero_image_block.isml`.
224+
225+
**Handling colors (string or color picker object):** If an attribute can be a hex string or a color picker object `{ color: "#hex" }`, use a small helper so the script works with both:
226+
227+
```javascript
228+
function getColor(colorAttr) {
229+
if (!colorAttr) return '';
230+
if (typeof colorAttr === 'string' && colorAttr.trim()) return colorAttr.trim();
231+
if (colorAttr.color) return colorAttr.color;
232+
return '';
233+
}
234+
```
235+
218236
### Component Template (templates/experience/components/banner.isml)
219237

220238
```html
@@ -260,7 +278,13 @@ module.exports.render = function (context) {
260278
| `category` | Category selector | Category object |
261279
| `product` | Product selector | Product object |
262280
| `page` | Page selector | Page object |
263-
| `custom` | JSON object | Object |
281+
| `custom` | JSON object or custom editor | Object (or editor-specific) |
282+
283+
**Enum — critical for component visibility:** Use a **string array** for `values`: `"values": ["left", "center", "right"]`. Do **not** use objects like `{ "value": "x", "display_value": "X" }`; that format can cause the component type to be rejected and **not appear** in the Page Designer component list.
284+
285+
**Custom and colors:** `type: "custom"` with e.g. `editor_definition.type: "styling.colorPicker"` requires a cartridge that provides that editor on the **Business Manager** site cartridge path. If the component does not show up in the editor, use `type: "string"` for color attributes (merchant types a hex). In the script, support both: accept a string or an object like `{ color: "#hex" }` (e.g. a small `getColor(attr)` helper that returns the string).
286+
287+
**default_value:** Used for storefront rendering only; it is **not** shown as preselected in the Page Designer visual editor.
264288

265289
## Region Definitions
266290

@@ -337,14 +361,25 @@ Organize components in the editor sidebar:
337361

338362
Common groups: `content`, `products`, `navigation`, `layout`, `media`
339363

364+
## If the component does not appear in Page Designer
365+
366+
1. **Enums:** Ensure all `enum` attributes use `"values": ["a", "b"]` (string array), not objects with `value`/`display_value`.
367+
2. **Custom editors:** Replace `type: "custom"` (e.g. color picker) with `type: "string"` for the problematic attributes and redeploy; if the component then appears, the issue is likely the custom editor or BM cartridge path.
368+
3. **Naming:** File and subdirectory names only alphanumeric or underscore.
369+
4. **region_definitions:** Component meta must include `region_definitions` (use `[]` if no nested regions).
370+
5. **Template path:** Script `Template('...')` path must match the template path under `templates/default/` (including subfolders like `experience/components/assets/...`).
371+
6. **Logs:** In Business Manager, **Administration > Site Development > Development Setup**, check error logs when opening Page Designer for script or meta errors related to your component type ID.
372+
7. **Code version:** Deploy the cartridge to the correct code version; in non-production, meta can be cached for a few seconds—try a code version switch or short wait.
373+
340374
## Best Practices
341375

342376
1. **Use `dw.util.Template`** for rendering (NOT `dw.template.ISML`)
343377
2. **Keep components self-contained** - avoid cross-component dependencies
344-
3. **Provide default values** for optional attributes
378+
3. **Provide default values** for optional attributes (they apply to rendering; not shown as preselected in the editor)
345379
4. **Group related attributes** in `attribute_definition_groups`
346380
5. **Use meaningful IDs** - they're used programmatically
347-
6. **Don't change type IDs** after merchants create content
381+
6. **Don't change type IDs or attribute types** after merchants create content (creates inconsistency with stored data); add a new component type and deprecate the old one if needed
382+
7. **Prefer string arrays for enums** and **string for colors** unless you control the BM cartridge path and custom editors
348383

349384
## Detailed Reference
350385

0 commit comments

Comments
 (0)