Block Presets (Developers)


What it is

Block Presets allow storage and reuse of block trees through YAML-backed configuration plus admin APIs.
A preset represents a root block node with recursive children, including translation-level attributes.

When to use it

Use presets when you need:
  • reusable layout primitives shared across editors,
  • controlled block tree templates validated against current block configuration,
  • a combined workflow of static preset definitions + editor-created presets.

How it works

Storage and precedence

BlockPresetStorage merges sources in this order:
  1. configured presets (fifty_deg_sylius_degditor_base.presets),
  2. user presets file (fifty_deg_sylius_degditor_base.presets_file).
If same id exists in both, file-based preset overrides configured one.

Admin API flow

Routes:
  • GET /%sylius_admin.path_name%/ajax/degditor/block-presets/
  • POST /%sylius_admin.path_name%/ajax/degditor/block-presets/
  • POST /%sylius_admin.path_name%/ajax/degditor/page/{pageId}/block-presets/{presetId}/apply/
Controller: BlockPresetAjaxController
  • createAction: reads existing block subtree, normalizes, validates, persists preset.
  • applyAction: validates preset, creates blocks recursively in current page context.

Validation rules

BlockPresetValidator enforces:
  • block type existence,
  • parent-child compatibility (allowed_inner_blocks),
  • attributes must exist in block configuration,
  • translation attributes must pass standard block validation semantics.

How to configure/use

Configure presets file path

1fifty_deg_sylius_degditor_base: 2 presets_file: '%kernel.project_dir%/config/degditor/%kernel.environment%/presets.yaml' 3

Configure inline presets

1fifty_deg_sylius_degditor_base: 2 presets: 3 hero_banner: 4 name: 'Hero banner' 5 description: 'Hero with image and CTA' 6 block: 7 type: 'hero' 8 adminTitle: 'Hero' 9 translations: [ ] 10 children: [ ] 11
The block types below are illustrative: replace them with registered block IDs and supply their required attributes. Presets are validated against the active block configuration.

File schema

1presets: 2 two_columns: 3 name: 'Two columns layout' 4 description: 'Container > row > two columns' 5 block: 6 type: 'container' 7 adminTitle: 'Container' 8 translations: 9 - locale: 'en_US' 10 attributes: { } 11 children: 12 - type: 'row' 13 adminTitle: 'Row' 14 translations: 15 - locale: 'en_US' 16 attributes: { } 17 children: [ ] 18

Common issues

Preset applies in one context but not another

  • Expected behavior if parent block forbids preset root type.
  • Validate allowed_inner_blocks of target parent.

Preset fails after block config changes

  • Stored attributes may no longer match current block definition.
  • Recreate or migrate preset payload.

File write errors when saving from admin

  • Check filesystem permissions on presets directory/file.
  • Ensure directory can be created by app process.

Related docs

Your next step

Bring DegDitor to your Sylius store

Try the plugin

Experience the best features at no cost

Get a better understanding of DegDitor and how it works

Test it risk-free and see the results

Try it

Get a demo

Get a personalized demo tailored to your unique needs

Discover how reusable blocks speed up content creation

Evaluate DegDitor against your requirements

Get a demo

Find the right fit for your store

Tell us about your Sylius store and content needs. Talk to sales to explore the right DegDitor license, discuss integration, and plan your next steps.

Talk to sales