A module for Silverstripe CMS that allows CMS users to define reusable page layouts, known as "templates" or "skeletons". These templates provide a predefined set of Elemental blocks that can be used to quickly create pages with consistent layouts and content.
- Predefined Templates: Create reusable templates with predefined Elemental blocks.
- Page Creation from Templates: Quickly create new pages based on existing templates.
- Template Creation from Pages: Generate templates from existing pages, including their Elemental blocks.
- Configurable Defaults: Populate Elemental blocks with default values defined in YAML configuration.
- Silverstripe CMS ^5
- DNADesign Elemental module ^5.2
Install the module via Composer:
composer require dynamic/silverstripe-elemental-templates
Run dev/build
to apply database changes.
- Navigate to the "Elemental Templates" section in the CMS.
- Click "Add Template".
- Fill in the template details:
- Title: Name of the template.
- Page Type: Select the page type this template is compatible with.
- Elements: Add Elemental blocks to the template.
- Save the template.
- Go to the "Pages" section in the CMS.
- Click "Add Page".
- Select the desired page type.
- In the "Template" dropdown, choose a template to apply to the new page.
- Complete the remaining page details and save.
The selected template's Elemental blocks will be duplicated and added to the new page.
- Open the page you want to use as the basis for a template.
- In the "More Options" menu, click "Create Blocks Template".
- A new template will be created with the same Elemental blocks as the page.
- Edit the template as needed in the "Elemental Templates" section.
The module supports pre-populating Elemental blocks with default values. This is configurable via YAML and supports database fields and relationships.
Dynamic\ElememtalTemplates\Models\Template:
populate:
DNADesign\Elemental\Models\ElementContent:
Title: "Default Title"
Content: "<p>Default content</p>"
Note: The $populate
static configuration is checked on the Template
class to determine whether default values should be applied when duplicating elements from a template.
We recognize that the current implementation only supports configuring population definitions for database fields. Expanding this functionality to include other types of data is a priority, and we are actively working on adding this feature to enhance the module's flexibility and usability.
The module logs key actions, such as template creation and Elemental block duplication, to the Silverstripe log file (silverstripe.log
). This can help diagnose issues during development.
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
This module is licensed under the BSD-3-Clause license. See the LICENSE file for details.
Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.
If the issue does look like a new bug:
- Create a new issue
- Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots and screencasts can help here.
- Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, Operating System, any installed SilverStripe modules.
Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.