Skip to content

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 packagedmf/sw6-plugin-cms-block-library
Plugin classDmf\CmsBlockLibrary\DmfCmsBlockLibrary
NamespaceDmf\CmsBlockLibrary
Version1.0.0
Shopware^6.7
PHP8.2+
ScopeAdmin-only, no storefront component

Installation

bash
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.sh

Admin-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

ColumnTypeNotes
idBINARY(16)UUID
nameVARCHAR(255)Display name
tagsJSON NULLOptional list of strings
block_typeVARCHAR(255)Original cms_block.type
block_configJSONSnapshot of block + slots
is_linkedTINYINT(1)1 = inserted as a live reference
created_at/updated_atDATETIME(3)

dmf_cms_saved_section

ColumnTypeNotes
idBINARY(16)UUID
nameVARCHAR(255)Display name
tagsJSON NULLOptional
section_typeVARCHAR(255)default, sidebar, …
section_configJSONSnapshot, section + blocks + slots
created_at/updated_atDATETIME(3)

API endpoints

All routes are scoped api and require admin authentication.

MethodRouteDescription
POST/api/search/dmf-cms-saved-blockDAL search
POST/api/dmf-cms-saved-blockcreate
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/importMultipart file upload
POST/api/_action/dmf-cms-block-library/{id}/syncPersist new block_config, propagate to all linked instances, invalidate cms-page-{id} cache tags
POST/api/search/dmf-cms-saved-sectionDAL search
POST/api/dmf-cms-saved-sectioncreate
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/importMultipart 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.dmfSavedBlockId and customFields.dmfLinked = true.
  • Live in-page mirroring: a watcher on page.sections propagates 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_config to 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 dmfLinked markers and invalidates their cms-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

  1. Open any Shopping Experience in the admin.
  2. Select a block, the right sidebar shows its settings and quickactions.
  3. Click Save as block, enter a name and optional tags, optionally toggle Save as linked block, then Save.

Reuse a saved block

  1. Open the block picker (left sidebar).
  2. Pick the Saved blocks category.
  3. 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_config via sw-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_config is 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.