netgen/layouts-sylius-bitbag
Netgen Layouts integration for Sylius with BitBag CMS support. Lets editors compose storefront pages from reusable layout blocks, Sylius content, and BitBag CMS elements, adding flexible layout-driven page building to product, category, and CMS pages.
This is a thin integration layer between Netgen Layouts (layout engine), Sylius (e-commerce), and BitBag Sylius CMS (CMS pages/blocks). It ships block handlers and value types so BitBag CMS content can be dropped into Netgen layouts and used as layout-resolution criteria. Do not expect documentation — read the bundle source and the parent netgen/layouts-sylius bundle first; this one mostly extends it.
Minimal steps:
composer.json constraints of all three):
composer require netgen/layouts-sylius netgen/layouts-sylius-bitbag bitbag/sylius-cms-plugin
config/bundles.php:
Netgen\Bundle\LayoutsSyliusBitBagBundle\NetgenLayoutsSyliusBitBagBundle::class => ['all' => true],
/admin/netgen-layouts), edit a layout, open the block library, and add a BitBag CMS Page or BitBag CMS Block block. Point it at an existing CMS page/block created through BitBag's admin.Where to look first:
DependencyInjection/ — what block definitions and value types get registered and under what names.Block/ (or Block/Handler/) — how CMS content is loaded and passed to the view.Resources/views/ — the Twig templates you will inevitably override.ValueType/ / QueryType/ — how CMS pages are resolved for rule matching and listing.Compose layouts around CMS content. The typical pattern is: BitBag CMS Page provides the canonical content object; Netgen Layouts resolves a layout for that page via a rule matching a bitbag_cms_page value type; the layout contains zones, and one of those zones contains a bitbag_cms_block block pulling the CMS block. Keep the "which CMS page am I on" resolution in a rule, not in Twig.
Rule-based targeting. Use the registered value types in netgen_layouts.yaml under value_definitions/rule_targets to target rules at specific CMS pages, CMS sections, or "any CMS page". This is the whole point of the integration — you get CMS-aware layout resolution without writing a custom resolver.
Reuse CMS blocks across layouts. Define a block of type bitbag_cms_block once, reference the same BitBag CMS block from several layouts, and edit content in BitBag's own admin. Editors edit content in the CMS plugin, marketers reorganize in Netgen Layouts. Preserve that split.
Twig rendering. Render with the bundle’s templates and only override where necessary:
{{ netgen_layouts_render('layout', { layout_resolver: 'my_resolver' }) }}
For CMS blocks inside a layout, the block view template is chosen from the block definition’s views. Add your own view entries in netgen_layouts.yaml and let the CMS editor pick via the block’s view selector.
Query types for listings. If the bundle exposes query types for listing BitBag pages (e.g. in a "content list" block), configure them in the layout block’s parameters so the CMS side owns the data while the layout owns presentation.
Integration tip — content-first routing. Let BitBag’s dynamic router own the URL, and hook Netgen Layouts rendering into the BitBag page controller via a controller override or a kernel-view/response listener. Never let Netgen Layouts own routing for CMS pages; that produces duplicate-slug conflicts.
Testing hooks. Because of the version coupling (Sylius + BitBag CMS + Netgen Layouts), add a smoke test that boots the kernel, fetches / and a CMS page URL, and asserts HTTP 200. That single test catches most upgrade breakage in this stack.
composer.json and treat a minor bump of any of the three parents as a migration. Read the diff of netgen/layouts-sylius on every upgrade — this bundle inherits its breakage.{% if content is not empty %}{{ ... }}{% endif %}
postUpdate/postPersist subscriber) to call Netgen Layouts’ cache clear for layouts referencing that block, or accept "clear cache after editing content" as an operational note for editors.Resources/views/ into templates/bundles/NetgenLayoutsSyliusBitBagBundle/ (Symfony bundle override convention) rather than editing vendor files — you will need to, since the default views are minimal.netgen_layouts.php (or .yml) doesn’t have a block_definitions key that replaces rather than merges — use YAML merge (!php/const / _defaults) or import the bundle’s config explicitly.bin/console debug:container netgen_layouts.layout_resolver and debug:container --tag=netgen_layouts.block_definition to confirm what this bundle actually registered. When a block or rule target seems missing, this is faster than reading the source.netgen_layouts.block_definitions, netgen_layouts.value_types, and the block handler service tag netgen_layouts.block.handler. Registering your own handler here is often cleaner than forking this bundle — especially if you need to add fields (e.g. "show excerpt only") to the CMS block type.How can I help you explore Laravel packages today?