feat: [Page Builder] Config: Elemental configuration, allowed block types per page#219
feat: [Page Builder] Config: Elemental configuration, allowed block types per page#219
Conversation
…ypes per page - elemental.yml: attaches ElementalAreasExtension to Page, enables live preview - elemental-blocks.yml: per-page-type block whitelists - Page: ContentBlock, TextBlock, HTMLBlock, ImageBlock - LandingPage: full palette (18+ block types including CTA, Quote, Gallery, Hero, etc.) - ErrorPage: no blocks - HomePage (optional): curated subset - Documents available blocks and how to override Relates to #133 (Page Builder system, issue #135)
There was a problem hiding this comment.
Pull request overview
Adds SilverStripe Elemental configuration to enable page-builder “blocks” and define per-page-type whitelists for which blocks can be added in the CMS (issue #135).
Changes:
- Introduces
app/_config/elemental.ymlto attach Elemental toPageand enable live preview. - Introduces
app/_config/elemental-blocks.ymlto defineallowed_elementsper PageType (Page, LandingPage, ErrorPage, optional HomePage).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| app/_config/elemental.yml | Adds global Elemental config (extension + block defaults + live preview). |
| app/_config/elemental-blocks.yml | Adds per-page-type allowed_elements whitelists (including an optional HomePage override). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,32 @@ | |||
| --- | |||
| Name: elemental | |||
| After: framework/*, cms/*, elemental/* | |||
There was a problem hiding this comment.
After: is written as a single scalar value containing commas (framework/*, cms/*, elemental/*). In YAML this won’t be treated as multiple ordering rules, so the config load order likely won’t behave as intended. Use a YAML list (multiple - entries) or a single After: target that matches an actual config name/anchor.
| After: framework/*, cms/*, elemental/* | |
| After: | |
| - framework/* | |
| - cms/* | |
| - elemental/* |
| # Attach ElementalArea to standard Page | ||
| Page: | ||
| extensions: | ||
| - DNADesign\Elemental\Extensions\ElementalAreasExtension |
There was a problem hiding this comment.
This config unconditionally references Elemental classes (e.g. DNADesign\Elemental\Extensions\ElementalAreasExtension, DNADesign\Elemental\Models\BaseElement), but composer.json in this repo doesn’t require the Elemental module. Without gating (e.g. Only: { moduleexists: 'dnadesign/silverstripe-elemental' }) this can break dev/build when the module isn’t installed.
| App\PageBuilder\Blocks\ContentBlock: | ||
| allow_page_editing: true | ||
|
|
||
| App\PageBuilder\Blocks\TextBlock: | ||
| allow_page_editing: true | ||
|
|
||
| App\PageBuilder\Blocks\HTMLBlock: | ||
| allow_page_editing: true | ||
|
|
||
| App\PageBuilder\Blocks\ImageBlock: | ||
| allow_page_editing: true | ||
|
|
There was a problem hiding this comment.
The block classes configured here (App\PageBuilder\Blocks\ContentBlock, TextBlock, HTMLBlock, ImageBlock) don’t exist anywhere in this repository (no App\PageBuilder code is present). As-is, these settings won’t take effect and may lead to missing/empty block options. Either add these block classes, correct the namespaces to match existing classes, or remove the config until the blocks exist.
| App\PageBuilder\Blocks\ContentBlock: | |
| allow_page_editing: true | |
| App\PageBuilder\Blocks\TextBlock: | |
| allow_page_editing: true | |
| App\PageBuilder\Blocks\HTMLBlock: | |
| allow_page_editing: true | |
| App\PageBuilder\Blocks\ImageBlock: | |
| allow_page_editing: true |
| @@ -0,0 +1,59 @@ | |||
| --- | |||
| Name: elemental-blocks | |||
There was a problem hiding this comment.
This file also unconditionally configures Elemental classes (allowed_elements includes DNADesign\Elemental\Models\* and many App\PageBuilder\Blocks\*), but the Elemental module isn’t declared in composer.json. Consider adding an Only: { moduleexists: 'dnadesign/silverstripe-elemental' } guard (or adding the dependency in this PR) to avoid config breaking when Elemental isn’t installed.
| Name: elemental-blocks | |
| Name: elemental-blocks | |
| Only: | |
| moduleexists: 'dnadesign/silverstripe-elemental' |
| # LandingPage — full palette of blocks | ||
| App\PageBuilder\LandingPage: | ||
| allowed_elements: | ||
| - App\PageBuilder\Blocks\ContentBlock | ||
| - App\PageBuilder\Blocks\TextBlock | ||
| - App\PageBuilder\Blocks\HTMLBlock | ||
| - App\PageBuilder\Blocks\ImageBlock | ||
| - App\PageBuilder\Blocks\CtaBlock | ||
| - App\PageBuilder\Blocks\QuoteBlock | ||
| - App\PageBuilder\Blocks\GalleryBlock | ||
| - App\PageBuilder\Blocks\HeroBlock | ||
| - App\PageBuilder\Blocks\AccordionBlock | ||
| - App\PageBuilder\Blocks\VideoBlock | ||
| - App\PageBuilder\Blocks\CalloutBlock | ||
| - App\PageBuilder\Blocks\PricingBlock | ||
| - App\PageBuilder\Blocks\TabsBlock | ||
| - App\PageBuilder\Blocks\StatsBlock | ||
| - App\PageBuilder\Blocks\FAQBlock | ||
| - App\PageBuilder\Blocks\FileDownloadBlock | ||
| - App\PageBuilder\Blocks\DividerBlock | ||
| - App\PageBuilder\Blocks\SpacerBlock | ||
| - DNADesign\Elemental\Models\ElementalContent | ||
| - DNADesign\Elemental\Models\TitleElement | ||
|
|
There was a problem hiding this comment.
allowed_elements references many App\PageBuilder\Blocks\* classes (and App\PageBuilder\LandingPage) that do not exist anywhere in this repository. With no corresponding PHP classes, the CMS “Add Block” dialog can end up empty or erroring depending on how Elemental resolves the whitelist. Update this list to only include classes that actually exist in the codebase, or land the block/page classes in the same PR.
| only: | ||
| 'exists': 'App\Page\HomePage' |
There was a problem hiding this comment.
The conditional config block for App\Page\HomePage uses only: (lowercase) and an 'exists' condition key, which doesn’t match the existing conditional config pattern used elsewhere in this repo (Only: with keys like moduleexists, e.g. app/_config/mimevalidator.yml). As written, this condition is likely ignored, so the HomePage whitelist may apply unexpectedly or never apply. Use the standard Only: casing and a supported condition (e.g. class/module existence).
| only: | |
| 'exists': 'App\Page\HomePage' | |
| Only: | |
| classexists: App\Page\HomePage |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,59 @@ | |||
| --- | |||
| Name: elemental-blocks | |||
| After: elemental/* | |||
There was a problem hiding this comment.
If this file is intended to override defaults set in app/_config/elemental.yml (Name: elemental), After: elemental/* does not guarantee ordering relative to that named config. Consider using After: '#elemental' (or otherwise explicitly ordering against the app config name) so the per-page whitelists reliably apply last.
| After: elemental/* | |
| After: '#elemental' |
| - App\PageBuilder\Blocks\ImageBlock | ||
|
|
||
| # LandingPage — full palette of blocks | ||
| App\PageBuilder\LandingPage: |
There was a problem hiding this comment.
App\\PageBuilder\\LandingPage is configured here, but there is no LandingPage class under app/src in this repo. If the page type is expected to come from another module, ensure that module is required/autoloaded; otherwise this per-page whitelist will never take effect.
| App\PageBuilder\LandingPage: | |
| App\PageBuilder\LandingPage: | |
| only: | |
| 'exists': 'App\PageBuilder\LandingPage' |
Implements #135
Configuration
How to override
Blocks are configured via YAML. Additional PageTypes can add their own allowed_elements list to elemental-blocks.yml.