DmfCmsBlockLibrary
Centralised library for saved CMS blocks and sections inside Shopware 6.7 Shopping Experiences. Editors persist any block or full section (with all slots and elements), reuse it across any Shopping Experience, and copy/paste blocks or sections between pages within an admin session, recurring layouts no longer need to be rebuilt by hand.
Quick facts
| Composer package | dmf/sw6-plugin-cms-block-library |
| Plugin class | Dmf\CmsBlockLibrary\DmfCmsBlockLibrary |
| Namespace | Dmf\CmsBlockLibrary |
| Version | 1.0.0 |
| Shopware | ^6.7 |
| PHP | 8.2+ |
| Scope | Admin-only, no storefront component |
Installation
composer require dmf/sw6-plugin-cms-block-library
bin/console plugin:refresh
bin/console plugin:install --activate DmfCmsBlockLibrary
bin/console cache:clear
bin/console database:migrate --all DmfCmsBlockLibrary
./bin/build-administration.shAdmin-only extension
No storefront build required. Saved entries are templates for the page builder; rendering happens through the regular cms_block and cms_section once they have been inserted into a page.
Configuration
DmfCmsBlockLibrary ships no plugin configuration. Operations happen directly in the admin under Content → Block library and Content → Section library.
Features
- Saved blocks: persist any CMS block with all slots and reuse it in any Shopping Experience.
- Linked blocks: alternative insert mode that keeps every inserted instance synchronised with the library entry. Edits made on any linked instance propagate live to all other linked instances and to the library entry itself.
- Saved sections: persist a full section (including all blocks and elements) and reinsert it before/after any section.
- Block library overview under Content → Block library: list, search, preview, rename, delete, import, export. The Type column distinguishes static copies from linked blocks.
- Section library overview under Content → Section library with the same feature set.
- Picker category Saved blocks, drag a saved block onto the stage to materialise a fresh
cms_block(new UUIDs). When the library entry is marked as linked, the inserted block keeps a reference to the library entry. - Block copy/paste in the block sidebar: paste before or after any block on any page within the same admin session.
- Section gear button opens Section settings: rename, copy, paste-after, save to library, insert saved section before/after.
- JSON import/export per library.
Data model
Two DAL entities with standard admin-API CRUD:
dmf_cms_saved_block
| Column | Type | Notes |
|---|---|---|
id | BINARY(16) | UUID |
name | VARCHAR(255) | Display name |
tags | JSON NULL | Optional list of strings |
block_type | VARCHAR(255) | Original cms_block.type |
block_config | JSON | Snapshot of block + slots |
is_linked | TINYINT(1) | 1 = inserted as a live reference |
created_at/updated_at | DATETIME(3) |
dmf_cms_saved_section
| Column | Type | Notes |
|---|---|---|
id | BINARY(16) | UUID |
name | VARCHAR(255) | Display name |
tags | JSON NULL | Optional |
section_type | VARCHAR(255) | default, sidebar, … |
section_config | JSON | Snapshot, section + blocks + slots |
created_at/updated_at | DATETIME(3) |
API endpoints
All routes are scoped api and require admin authentication.
| Method | Route | Description |
|---|---|---|
| POST | /api/search/dmf-cms-saved-block | DAL search |
| POST | /api/dmf-cms-saved-block | create |
| PATCH | /api/dmf-cms-saved-block/{id} | update |
| DELETE | /api/dmf-cms-saved-block/{id} | delete |
| GET | /api/_action/dmf-cms-block-library/export[?ids=…] | JSON download |
| POST | /api/_action/dmf-cms-block-library/import | Multipart file upload |
| POST | /api/_action/dmf-cms-block-library/{id}/sync | Persist new block_config, propagate to all linked instances, invalidate cms-page-{id} cache tags |
| POST | /api/search/dmf-cms-saved-section | DAL search |
| POST | /api/dmf-cms-saved-section | create |
| PATCH | /api/dmf-cms-saved-section/{id} | update |
| DELETE | /api/dmf-cms-saved-section/{id} | delete |
| GET | /api/_action/dmf-cms-section-library/export[?ids=…] | JSON download |
| POST | /api/_action/dmf-cms-section-library/import | Multipart file upload |
UUIDs
On import, every UUID is regenerated, the same payload can be imported repeatedly without collisions.
Linked blocks
When a linked block is inserted into a CMS page:
- The block stores
customFields.dmfSavedBlockIdandcustomFields.dmfLinked = true. - Live in-page mirroring: a watcher on
page.sectionspropagates slot config changes to every sibling instance of the same library entry on the current page. - Live library sync (debounced): the same watcher pushes the changed
block_configto the sync route after ~800 ms idle. The library entry stays current without an explicit save. - Auto-sync on save: when the CMS page is saved, all linked blocks on the page are collected and synced per unique saved-block ID.
- Cache invalidation: the sync route resolves all CMS pages with matching
dmfLinkedmarkers and invalidates theircms-page-{id}tags. - Storefront rendering is unchanged: the sync route writes directly into
cms_slot_translation.config, no runtime substitution required.
Usage
Save a block
- Open any Shopping Experience in the admin.
- Select a block, the right sidebar shows its settings and quickactions.
- Click Save as block, enter a name and optional tags, optionally toggle Save as linked block, then Save.
Reuse a saved block
- Open the block picker (left sidebar).
- Pick the Saved blocks category.
- Drag an entry onto the stage.
Section settings (gear icon)
Every section shows a cog icon next to the existing section actions. The modal exposes:
- General: editable section name (live binding, also visible in the navigator).
- Actions: Copy section, Paste section after (active when the clipboard contains a section), Save section.
- Insert saved section: pick from the saved-section library, insert Before / After relative to the current section. New UUIDs are generated for the section, all blocks, and all slots.
Known limitations
Clipboard scope
Block and section clipboards live in sessionStorage. They survive navigation between pages within one admin tab, but closing the tab clears them. Cross-tab paste is not supported.
- Import/export is JSON only: no Shopware Import/Export profile integration. Exported files are not portable across major schema changes.
- Linked block editor uses raw JSON. The Edit linked block modal exposes the
block_configviasw-code-editor. There is no in-place WYSIWYG editor, the CMS editor remains the recommended path for non-technical edits. - Linked block scope. Only the block-level
block_configis synchronised. Per-page wrapper fields (cssClass,marginTop,backgroundColor) and section assignment remain page-local. - Sync writes through to
cms_slot_translation.config: language-specific overrides are overwritten. - Live mirroring is per-page only. Cross-instance mirroring on the open page is immediate; instances on other pages update once the debounced library sync completes and the storefront cache is invalidated.