dynamic / silverstripe-elemental-templates
Elemental Templates
Installs: 730
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 2
Open Issues: 3
Type:silverstripe-vendormodule
Requires
- php: ^8.1
- dnadesign/silverstripe-elemental: ^5.0
- silverstripe/vendor-plugin: ^2
Requires (Dev)
This package is auto-updated.
Last update: 2025-03-19 19:55:01 UTC
README
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.
Features
- 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.
Requirements
- Silverstripe CMS ^5
- DNADesign Elemental module ^5.2
Installation
Install the module via Composer:
composer require dynamic/silverstripe-elemental-templates
Run dev/build
to apply database changes.
Usage
Creating a Template
- 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.
Creating a Page from a 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.
Creating a Template from an Existing 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.
Populating Template Elements
The module supports pre-populating Elemental blocks with default values. This is configurable via YAML and supports database fields and relationships.
Example YAML Configuration
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.
Roadmap
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.
Logging and Debugging
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.
Contributing
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
License
This module is licensed under the BSD-3-Clause license. See the LICENSE file for details.
Maintainers
Bugtracker
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.
Development and contribution
If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.